summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2013-01-06 12:57:33 +0000
committerLee Jarvis <ljjarvis@gmail.com>2013-01-06 12:57:33 +0000
commit4dee434894ea5f63d1dcb28f235709b19b6380db (patch)
treeab66fa271c701e3c18f1678fab96ebee4fb05f03 /README.md
parent2e7165230be95906963b600216e0712edbc8e423 (diff)
downloadslop-4dee434894ea5f63d1dcb28f235709b19b6380db.tar.gz
added list/range/autocreate docs to readme
Diffstat (limited to 'README.md')
-rw-r--r--README.md56
1 files changed, 51 insertions, 5 deletions
diff --git a/README.md b/README.md
index b436e2a..cc67c55 100644
--- a/README.md
+++ b/README.md
@@ -82,13 +82,59 @@ All of these options can be sent to `Slop.new` or `Slop.parse` in Hash form.
* `longest_flag` - The longest string flag, used to aid configuring help
text. **default:** *0*.
-Features
---------
+Lists
+-----
+
+```ruby
+opts = Slop.parse do
+ on :l=, as: Array
+end
+# ruby run.rb -l one,two
+opts[:l] #=> ["one", "two"]
+# ruby run.rb -l one,two -l three
+opts[:l] #=> ["one", "two", "three"]
+```
-Check out the following wiki pages for more features:
+You can also specify a delimiter and limit.
+
+```ruby
+opts = Slop.parse do
+ on :l=, as: Array, delimiter: ':', limit: 2
+end
+# ruby run.rb -l one:two:three
+opts[:l] #=> ["one", "two:three"]
+```
-* [Ranges](https://github.com/injekt/slop/wiki/Ranges)
-* [Auto Create](https://github.com/injekt/slop/wiki/Auto-Create)
+Ranges
+------
+
+```ruby
+opts = Slop.parse do
+ on :r=, as: Range
+end
+# ruby run.rb -r 1..10
+opts[:r] #=> 1..10
+# ruby run.rb -r 1...10
+opts[:r] #=> 1...10
+# ruby run.rb -r 1-10
+opts[:r] #=> 1..10
+# ruby run.rb -r 1,10
+opts[:r] #=> 1..10
+```
+
+Autocreate
+----------
+
+Slop has an 'autocreate' feature. This feature is intended to create
+options on the fly, without having to specify them yourself. In some case,
+uses this code could be all you need in your application:
+
+```ruby
+# ruby run.rb --foo bar --baz --name lee
+opts = Slop.parse(autocreate: true)
+opts.to_hash #=> {:foo=>"bar", :baz=>true, :name=>"lee"}
+opts.fetch_option(:name).expects_argument? #=> true
+```
Woah woah, why you hating on OptionParser?
------------------------------------------