summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-01-08 12:05:24 +0000
committerLee Jarvis <ljjarvis@gmail.com>2013-01-08 12:05:24 +0000
commit52132159e28fefec43c523108c1884de84f0247d (patch)
tree4c87251b95dd108711fbfee0c1702a883a4710c7 /README.md
parentc7ec0c90677b0997c0eb2e7735201d78a2a7894f (diff)
downloadslop-52132159e28fefec43c523108c1884de84f0247d.tar.gz
added to_hash(true) example to commands
Diffstat (limited to 'README.md')
-rw-r--r--README.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/README.md b/README.md
index 0943a6d..c8a28cb 100644
--- a/README.md
+++ b/README.md
@@ -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?