diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2013-01-08 12:05:24 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2013-01-08 12:05:24 +0000 |
commit | 52132159e28fefec43c523108c1884de84f0247d (patch) | |
tree | 4c87251b95dd108711fbfee0c1702a883a4710c7 /README.md | |
parent | c7ec0c90677b0997c0eb2e7735201d78a2a7894f (diff) | |
download | slop-52132159e28fefec43c523108c1884de84f0247d.tar.gz |
added to_hash(true) example to commands
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -123,6 +123,7 @@ opts = Slop.parse do command 'add' do on :v, :verbose, 'Enable verbose more' + on :name, 'Your name' run do |opts, args| puts "You ran 'add' with options #{opts.to_hash} and args: #{args.inspect}" @@ -132,8 +133,10 @@ end # ruby run.rb -v #=> Version 1.0 -# ruby add -v foo -#=> You ran 'add' with options {:verbose=>true} and args ["foo"] +# ruby add -v foo --name Lee +#=> You ran 'add' with options {:verbose=>true,:name=>"Lee"} and args ["foo"] +opts.to_hash(true) # Pass true to tell Slop to merge sub-command option values. +# => { :v => nil, :add => { :v => true, :name => "Lee" } } ``` Woah woah, why you hating on OptionParser? |