-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trap interrupt during option input #101
Conversation
Looks good. |
@config.company = ask('Company name? ') { |q| q.default = @config.company } | ||
@config.author = ask('Author name? ') { |q| q.default = @config.author } | ||
@config.prefix = ask('Prefix? ') { |q| q.default = @config.prefix }.upcase | ||
begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the whole method is in the begin, you don't need it:
def foo
bar
baz
rescue SpecificErrorClass
bat
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, using begin
is also fine. We emphatically do not have a style guide for this ;)
Yup. No better way I can think of to capture interrupts. |
@config.author = ask('Author name? ') { |q| q.default = @config.author } | ||
@config.prefix = ask('Prefix? ') { |q| q.default = @config.prefix }.upcase | ||
rescue Interrupt, EOFError | ||
exit 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be exit 0
for EOFError
- that is, I think EOFError
is ctrld, and I know that ctrld should be a 0
(successful) exit.
Great refactoring. |
* Extract OptionFetcher This class handles fetching the options from the user, and manages the various interrupt signals during input Fixes #81
Fixes #81