diff options
author | Eric Anderson <eric@pixelwareinc.com> | 2012-01-26 13:36:03 -0600 |
---|---|---|
committer | Eric Anderson <eric@pixelwareinc.com> | 2012-01-26 13:53:53 -0600 |
commit | 6eb32c028f1f830a5927ae09a59d2706cc55fa82 (patch) | |
tree | 7b7daecd5ee49f24e9ebe2dbadace03b23bd55c0 /README.md | |
parent | 3718e9ba0cb2f6289016a3629948292cee042162 (diff) | |
download | slop-6eb32c028f1f830a5927ae09a59d2706cc55fa82.tar.gz |
New support_dash option. Will treat --database-name like --database_name
In your ruby code we really prefer underscores. This way we can write:
on :database_name=
Instead of the uglier:
on 'database-name='
Also it means we can use the magic present? method. So we can do:
opts.database_name?
Instead of the uglier:
opts.present? 'database-name'
But using an underscore to make our Ruby prettier makes our command line
options uglier. We end up with a mix of - and _ which is confusing to users.
This patch adds a new option called :support_dash which will allow users to
type --database-name but still allow the ruby code to specify :database_name
and opts.database_name? It works similar to the existing case option that allows
options to be case insensitive.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -73,6 +73,8 @@ All of these options can be sent to `Slop.new` or `Slop.parse` in Hash form. * `banner` - Set this options banner text. **default:** *nil*. * `ignore_case` - When enabled, `-A` will look for the `-a` option if `-A` does not exist. **default:** *false*. +* `support_dash` - Will treat --no-database as if you typed in --no_database. + **default:** *false* * `autocreate` - Autocreate options on the fly. **default:** *false*. * `arguments` - Force all options to expect arguments. **default:** *false*. * `optional_arguments` - Force all options to accept optional arguments. @@ -130,4 +132,4 @@ opts = Slop.parse do end opts.to_hash #=> { :name => 'lee', :age => 105 } -```
\ No newline at end of file +``` |