diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2013-01-08 11:48:31 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2013-01-08 11:48:31 +0000 |
commit | 55a1ee79f603d89a76bc5dac7a5c75e97ed2d17c (patch) | |
tree | c12f038aabee0ec012ab2abe660ee26d9361a479 /README.md | |
parent | 93ec4d29629be94747d98e924369bc4e49606aea (diff) | |
download | slop-55a1ee79f603d89a76bc5dac7a5c75e97ed2d17c.tar.gz |
updated readme with command example
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -110,6 +110,32 @@ opts.to_hash #=> {:foo=>"bar", :baz=>true, :name=>"lee"} opts.fetch_option(:name).expects_argument? #=> true ``` +Commands +-------- + +Slop supports git style sub-commands, like so: + +```ruby +opts = Slop.parse do + on '-v', 'Print the version' do + puts "Version 1.0" + end + + command 'add' do + on :v, :verbose, 'Enable verbose more' + + run do |opts, args| + puts "You ran 'add' with options #{opts.to_hash} and args: #{args.inspect}" + end + end +end + +# ruby run.rb -v +#=> Version 1.0 +# ruby add -v foo +#=> You ran 'add' with options {:verbose=>true} and args ["foo"] +``` + Woah woah, why you hating on OptionParser? ------------------------------------------ |