Browse Source

Merge pull request 'add example hidden option' (#5) from example into master

Reviewed-on: https://gitoa.ru/go-4devs/console/pulls/5
pull/6/head v0.1.1
andrey 2 years ago
parent
commit
44d8837dbc
  1. 3
      example/cmd/config/main.go
  2. 2
      example/pkg/command/args.go

3
example/cmd/config/main.go

@ -16,7 +16,8 @@ const (
AppName = "console"
)
// FDEVS_CONSOLE_CAT=env go run cmd/config/main.go fdevs:console:arg -b tmp.
// FDEVS_CONSOLE_CAT=env FDEVS_CONSOLE_HIDDEN=2022-09-18T23:07:49+03:00 go run cmd/config/main.go fdevs:console:arg -b tmp.
// FDEVS_CONSOLE_CAT=env go run cmd/config/main.go fdevs:console:arg --hidden=2022-09-18T23:07:49+03:00 -b tmp.
func main() {
env := config.New(Namespace, AppName, []config.Provider{
env.New(),

2
example/pkg/command/args.go

@ -20,6 +20,7 @@ func Args() *console.Command {
option.String("bar", "required bar option", option.Required, option.Short('b')),
option.String("cat", "cat option", option.Short('c')),
option.Time("time", "time example"),
option.Time("hidden", "hidden time example", option.Hidden),
)
return nil
@ -29,6 +30,7 @@ func Args() *console.Command {
out.Println(ctx, "bar: <info>", in.Option(ctx, "bar").String(), "</info>")
out.Println(ctx, "cat: <info>", in.Option(ctx, "cat").String(), "</info>")
out.Println(ctx, "time: <info>", in.Option(ctx, "time").Time().Format(time.RFC3339), "</info>")
out.Println(ctx, "hidden: <info>", in.Option(ctx, "hidden").Time().Format(time.RFC3339), "</info>")
return nil
},

Loading…
Cancel
Save