Skip to content
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

Merged
merged 1 commit into from
Mar 12, 2014
Merged

Trap interrupt during option input #101

merged 1 commit into from
Mar 12, 2014

Conversation

gfontenot
Copy link
Member

Fixes #81

@hyperspacemark
Copy link
Contributor

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

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

Copy link
Contributor

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 ;)

@calebhearth
Copy link

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

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.

@mike-burns
Copy link

Great refactoring.

* Extract OptionFetcher
  This class handles fetching the options from the user, and manages the
  various interrupt signals during input

Fixes #81
@gfontenot gfontenot merged commit 88f55e4 into master Mar 12, 2014
@gfontenot gfontenot deleted the gf-trap-interrupt branch March 12, 2014 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trap interrupt signals and exit cleanly
5 participants