summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
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?