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

Configliere::Commandline should not accept multiple flags as one string #17

Open
kornypoet opened this issue Dec 11, 2012 · 0 comments
Open

Comments

@kornypoet
Copy link
Contributor

This is potentially dangerous. Given a file test.rb with the following code:

#!/usr/bin/env/ruby

require 'configliere' ; Settings.use(:commandline)

Settings.define :launch_nukes, flag: 'h'
Settings.define :erase_drive, flag: 'e'
Settings.define :punch_baby, flag: 'l'
Settings.define :give_up_on_life, flag: 'p'
Settings.resolve!

p Settings

Accidentally typing -help instead of --help could lead to potentially disastrous outcomes.

# ./test.rb -help
{ :launch_nukes => true, :erase_drive => true, :punch_baby => true, :give_up_on_life => true }

Config params should be descriptive, and while shortening config to single letter flags is fun, it should be used with caution. Asking that the above invocation should fail instead of "working" isn't going too far. I argue that command line flags must be followed by a space in order to prevent the above scenario.

# ./test.rb -help
Configliere::ParserError "Detected command line flag without a space! Oh noes!"

This doesn't seem too verbose and actually clears up parsing logic.

# ./test.rb -h -e -l -p
{ :launch_nukes => true, :erase_drive => true, :punch_baby => true, :give_up_on_life => true }
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

No branches or pull requests

1 participant