Documentation
¶
Overview ¶
Package flagtype provides common flag.Value implementations. Each also implements flag.Getter for use with cli.State.GetFlag.
Flags: cli.FlagsFunc(func(f *flag.FlagSet) {
f.Var(flagtype.StringSlice(), "tag", "add a tag (repeatable)")
f.Var(flagtype.Enum("json", "yaml", "table"), "format", "output format")
f.Var(flagtype.StringMap(), "label", "key=value pair (repeatable)")
})
Inside Exec:
tags := s.GetFlag[[]string]("tag")
format := s.GetFlag[string]("format")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enum ¶
Enum returns a flag.Value restricted to allowed. Its value is retrieved as a string.
func EnumDefault ¶
EnumDefault is like Enum with a default value, also retrieved as a string. It panics if defaultVal is not allowed.
func Regexp ¶
Regexp returns a flag.Value that compiles its input as a regular expression. Its value is retrieved as *regexp.Regexp.
func StringMap ¶
StringMap returns a repeatable flag.Value that parses key=value pairs. Values may contain "="; the result is retrieved as map[string]string.
func StringSlice ¶
StringSlice returns a repeatable flag.Value retrieved as []string.
func URL ¶
URL returns a flag.Value that requires a URL with a scheme and host. Its value is retrieved as *url.URL.
Types ¶
This section is empty.