summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorLee Jarvis <ljjarvis@gmail.com>2014-11-19 22:32:20 +0000
committerLee Jarvis <ljjarvis@gmail.com>2014-11-19 22:32:20 +0000
commit9f8707f19f6e1835e5941b20af51887b7754719a (patch)
tree463144dfca09d8ae2d43067cb557c3dc802341af /README.md
parentc005e8a4a574d4407e39e4bd649f746a438cc8f0 (diff)
downloadslop-9f8707f19f6e1835e5941b20af51887b7754719a.tar.gz
Update readme and add type aliases
Diffstat (limited to 'README.md')
-rw-r--r--README.md25
1 files changed, 23 insertions, 2 deletions
diff --git a/README.md b/README.md
index 29bddef..747c402 100644
--- a/README.md
+++ b/README.md
@@ -33,8 +33,29 @@ opts.to_hash #=> { host: "192.168.0.1", port: 80, verbose: true, quiet: false }
Advanced Usage
--------------
-Printing Help
--------------
+This example is really just to describe how the underlying API works.
+It's not necessarily the best way to do it.
+
+```ruby
+opts = Slop::Options.new
+opts.banner = "usage: connect [options] ..."
+opts.separator ""
+opts.separator "Connection options:"
+opts.string "-H", "--hostname", "a hostname"
+opts.int "-p", "--port", "a port", default: 80
+opts.separator ""
+opts.separator "Extra options:"
+opts.array "--files", "a list of files to import"
+opts.bool "-v", "--verbose", "enable verbose mode"
+
+parser = Slop::Parser.new(opts)
+result = parser.parse(["--hostname", "192.168.0.1"])
+
+result.to_hash #=> { hostname: "192.168.0.1", port: 80,
+ # files: [], verbose: false }
+
+puts opts # prints out help
+```
Arrays
------