From 55389866ee35476f36919887756621d8ff75220d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 23 Jan 2013 21:56:26 -0500 Subject: [PATCH] add second example usage to README --- README.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8620785..7178398 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or install it yourself as: $ gem install yawpa -## Usage +## Example 1 require 'yawpa' @@ -36,6 +36,26 @@ Or install it yourself as: opts.each_pair do |opt, val| end +## Example 2 + + require 'yawpa' + + options = { + version: {}, + help: {short: 'h'}, + } + opts, args = Yawpa.parse(ARGV, options, posix_order: true) + if opts[:version] + puts "my app, version 1.2.3" + end + if args[0] == 'subcommand' + subcommand_options = { + 'server': {nargs: (1..2), short: 's'}, + 'dst': {nargs: 1, short: 'd'}, + } + opts, args = Yawpa.parse(args, subcommand_options) + end + ## Contributing 1. Fork it