From fd0e2d8bc3d1c647e6b051f48b8bedbe77934c0c Mon Sep 17 00:00:00 2001 From: Tim Rogers Date: Sat, 13 Jun 2015 18:40:32 +0100 Subject: Better handling of option names with multiple words --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 7a46538..77045a4 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,21 @@ opts = Slop.parse do |o| o.integer '--port', 'custom port', default: 80 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.on '--version', 'print the version' do puts Slop::VERSION exit end end -ARGV #=> -v --host 192.168.0.1 +ARGV #=> -v --host 192.168.0.1 --check-ssl-certificate -opts[:host] #=> 192.168.0.1 -opts.verbose? #=> true -opts.quiet? #=> false +opts[:host] #=> 192.168.0.1 +opts.verbose? #=> true +opts.quiet? #=> false +opts.check_ssl_certificate? #=> true -opts.to_hash #=> { host: "192.168.0.1", port: 80, verbose: true, quiet: false } +opts.to_hash #=> { host: "192.168.0.1", port: 80, verbose: true, quiet: false, check_ssl_certificate: true } ``` Option types -- cgit v1.2.1