diff options
author | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-19 22:32:20 +0000 |
---|---|---|
committer | Lee Jarvis <ljjarvis@gmail.com> | 2014-11-19 22:32:20 +0000 |
commit | 9f8707f19f6e1835e5941b20af51887b7754719a (patch) | |
tree | 463144dfca09d8ae2d43067cb557c3dc802341af /README.md | |
parent | c005e8a4a574d4407e39e4bd649f746a438cc8f0 (diff) | |
download | slop-9f8707f19f6e1835e5941b20af51887b7754719a.tar.gz |
Update readme and add type aliases
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -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 ------ |