From f581ba6c58b834504a87f8906cf639da00ada43d Mon Sep 17 00:00:00 2001 From: Martin Lees Date: Wed, 18 Dec 2019 17:35:29 +0100 Subject: [PATCH] Add timestampFlag docs Reason for this PR is that it makes the CI fail until #987 is merged --- docs/v2/manual.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/v2/manual.md b/docs/v2/manual.md index 5e04d4e..39c1baf 100644 --- a/docs/v2/manual.md +++ b/docs/v2/manual.md @@ -1150,6 +1150,45 @@ The default version flag (`-v/--version`) is defined as `cli.VersionFlag`, which is checked by the cli internals in order to print the `App.Version` via `cli.VersionPrinter` and break execution. + +### Timestamp Flag + +Using the timestamp flag is simple, You can look at time.Parse to get layout examples : https://golang.org/pkg/time/#example_Parse + + +``` go +package main + +import ( + "fmt" + "log" + "os" + + "github.com/urfave/cli/v2" +) + +func main() { + app := &cli.App{ + Flags: []cli.Flag { + &cli.TimestampFlag{Name: "meeting", Layout: "2006-01-02T15:04:05"}, + }, + Action: func(c *cli.Context) error { + fmt.Printf("%#v",c.Timestamp("meeting").String()) + return nil + }, + } + + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } +} +``` + + #### Customization The default flag may be customized to something other than `-v/--version` by