From 4579bbf129a8e607313bf03af8d24e0f79ed0aa4 Mon Sep 17 00:00:00 2001 From: ston1th Date: Sun, 15 Nov 2015 10:59:12 +0100 Subject: [PATCH] added description to README.md --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/README.md b/README.md index 2346557..26a1838 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,32 @@ app.Action = func(c *cli.Context) { ... ``` +You can also set a destination variable for a flag, to which the content will be scanned. +``` go +... +var language string +app.Flags = []cli.Flag { + cli.StringFlag{ + Name: "lang", + Value: "english", + Usage: "language for the greeting", + Destination: &language, + }, +} +app.Action = func(c *cli.Context) { + name := "someone" + if len(c.Args()) > 0 { + name = c.Args()[0] + } + if language == "spanish" { + println("Hola", name) + } else { + println("Hello", name) + } +} +... +``` + See full list of flags at http://godoc.org/github.com/codegangsta/cli #### Alternate Names