diff options
author | Eugene Otto <eotto@plaid.com> | 2022-09-30 02:24:13 -0700 |
---|---|---|
committer | Eugene Otto <eotto@plaid.com> | 2022-09-30 04:35:46 -0700 |
commit | 1bcf46b7907d4fc566a1382ad4eda4d0e9354e63 (patch) | |
tree | ee0f92886f2d46d1f4f6b0a63c93e068e8814dd2 /README.md | |
parent | 41af0db78bba76cc7faccbf6adb400e65274f3a3 (diff) | |
download | slop-1bcf46b7907d4fc566a1382ad4eda4d0e9354e63.tar.gz |
Fix explicitly false booleans
When a boolean option is explicitly set to `false`, e.g.:
```bash
--option=false
```
it enters slop as the string value `'false'`. This commit updates the
`BoolOption` option handler to interpret `'false'` and various other falsey
values (`false`, `'false'`, `'no'`, `'off'`, `'0'`) as logically false.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -22,17 +22,19 @@ opts = Slop.parse do |o| o.bool '-v', '--verbose', 'enable verbose mode' o.bool '-q', '--quiet', 'suppress output (quiet mode)' o.bool '-c', '--check-ssl-certificate', 'check SSL certificate for host' + o.bool '-k', '--use-keychain', 'store passphrase in OS keychain' o.on '--version', 'print the version' do puts Slop::VERSION exit end end -ARGV #=> -v --login alice --host 192.168.0.1 -m post --check-ssl-certificate +ARGV #=> -v --login alice --host 192.168.0.1 -m post --check-ssl-certificate --use-keychain false opts[:host] #=> 192.168.0.1 opts[:login] #=> alice opts[:method] #=> :post +opts[:use_keychain] #=> false opts.verbose? #=> true opts.quiet? #=> false opts.check_ssl_certificate? #=> true @@ -53,7 +55,7 @@ Built in Option types are as follows: ```ruby o.string #=> Slop::StringOption, expects an argument -o.bool #=> Slop::BoolOption, no argument, aliased to BooleanOption +o.bool #=> Slop::BoolOption, argument optional, aliased to BooleanOption o.integer #=> Slop::IntegerOption, expects an argument, aliased to IntOption o.float #=> Slop::FloatOption, expects an argument o.array #=> Slop::ArrayOption, expects an argument |