diff --git a/docs/v2/manual.md b/docs/v2/manual.md index 7d62546..9f338cd 100644 --- a/docs/v2/manual.md +++ b/docs/v2/manual.md @@ -28,6 +28,7 @@ cli v2 manual + [Customization](#customization-1) * [Version Flag](#version-flag) + [Customization](#customization-2) + * [Timestamp Flag](#timestamp-flag) * [Full API Example](#full-api-example) @@ -1208,51 +1209,6 @@ 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("%s", c.Timestamp("meeting").String()) - return nil - }, - } - - err := app.Run(os.Args) - if err != nil { - log.Fatal(err) - } -} -``` - -In this example the flag could be used like so : - -`myapp --meeting 2019-08-12T15:04:05` - -side note : quotes may be necessary around the date depending on your layout (if you have spaces for instance) - - #### Customization The default flag may be customized to something other than `-v/--version` by @@ -1318,6 +1274,49 @@ func main() { } ``` +### 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("%s", c.Timestamp("meeting").String()) + return nil + }, + } + + err := app.Run(os.Args) + if err != nil { + log.Fatal(err) + } +} +``` + +In this example the flag could be used like so : + +`myapp --meeting 2019-08-12T15:04:05` + +side note : quotes may be necessary around the date depending on your layout (if you have spaces for instance) + ### Full API Example **Notice**: This is a contrived (functioning) example meant strictly for API