From 39a21042e1cee02d9255ca90bbf9246d7f82fcbd Mon Sep 17 00:00:00 2001 From: Jeremy Saenz Date: Thu, 18 Jul 2013 11:58:14 -0700 Subject: [PATCH] Update README.md --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13fb2b0..b4e25bf 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,32 @@ GLOBAL OPTIONS ``` ### Arguments -WIP +You can lookup arguments by calling the `Args` function on cli.Context. + +``` go +... +cli.Action = func(c *cli.Context) { + println("Hello", c.Args()[0]) +} +... +``` ### Flags -WIP +Setting and querying flags is simple. +``` go +... +cli.Flags = []cli.Flag { + cli.StringFlag{"lang", "english", "language for the greeting"}, +} +cli.Action = func(c *cli.Context) { + if c.String("lang") == "spanish" { + println("Hola", c.Args()[0]) + } else { + println("Hello", c.Args()[0]) + } +} +... +``` ### Subcommands WIP