Documentation
¶
Index ¶
- func CheckInnerFlags(cmd cli.Command) error
- func WithInnerFlags(cmd cli.Command, innerFlagMap map[string][]HasOuterFlag) cli.Command
- type DateTimeValue
- type DateValue
- type Flag
- func (f *Flag[T]) Count() int
- func (f *Flag[T]) Get() any
- func (f Flag[T]) GetBodyPath() string
- func (f *Flag[T]) GetCategory() string
- func (f *Flag[T]) GetDefaultText() string
- func (f *Flag[T]) GetEnvVars() []string
- func (f Flag[T]) GetHeaderPath() string
- func (f Flag[T]) GetQueryPath() string
- func (f *Flag[T]) GetUsage() string
- func (f *Flag[T]) GetValue() string
- func (f Flag[T]) IsBodyRoot() bool
- func (f *Flag[T]) IsBoolFlag() bool
- func (f *Flag[T]) IsDefaultVisible() bool
- func (f *Flag[T]) IsMultiValueFlag() bool
- func (f *Flag[T]) IsRequired() bool
- func (f *Flag[T]) IsSet() bool
- func (f *Flag[T]) IsVisible() bool
- func (f *Flag[T]) Names() []string
- func (f *Flag[T]) PostParse() error
- func (f *Flag[T]) PreParse() error
- func (f *Flag[T]) Set(name string, val string) error
- func (f *Flag[T]) SetCategory(c string)
- func (f *Flag[T]) SetInnerField(field string, val any)
- func (f *Flag[T]) String() string
- func (f *Flag[T]) TakesValue() bool
- func (f *Flag[T]) TypeName() string
- type HasOuterFlag
- type InRequest
- type InnerFlag
- func (f *InnerFlag[T]) Get() any
- func (f *InnerFlag[T]) GetDefaultText() string
- func (f *InnerFlag[T]) GetEnvVars() []string
- func (f *InnerFlag[T]) GetOuterFlag() cli.Flag
- func (f *InnerFlag[T]) GetUsage() string
- func (f *InnerFlag[T]) GetValue() string
- func (f *InnerFlag[T]) IsBoolFlag() bool
- func (f *InnerFlag[T]) IsDefaultVisible() bool
- func (f *InnerFlag[T]) IsMultiValueFlag() bool
- func (f *InnerFlag[T]) IsSet() bool
- func (f *InnerFlag[T]) Names() []string
- func (f *InnerFlag[T]) PostParse() error
- func (f *InnerFlag[T]) PreParse() error
- func (f *InnerFlag[T]) Set(name string, rawVal string) error
- func (f *InnerFlag[T]) SetOuterFlag(flag cli.Flag)
- func (f *InnerFlag[T]) String() string
- func (f *InnerFlag[T]) TakesValue() bool
- func (f *InnerFlag[T]) TypeName() string
- type RequestContents
- type SettableInnerField
- type TimeValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckInnerFlags ¶
Helper function to verify that all inner flags have an outer flag set and follow the --foo.baz prefix format
func WithInnerFlags ¶
WithInnerFlags takes a command and a map of flag names to inner flags, and returns a modified command with the appropriate inner flags set.
Types ¶
type DateTimeValue ¶
type DateTimeValue string
func (*DateTimeValue) Parse ¶
func (d *DateTimeValue) Parse(s string) error
func (DateTimeValue) String ¶
func (d DateTimeValue) String() string
type DateValue ¶
type DateValue string
Time-related value types
type Flag ¶
type Flag[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | string | float64 | int64 | bool, ] struct { Name string // name of the flag Category string // category of the flag, if any DefaultText string // default text of the flag for usage purposes HideDefault bool // whether to hide the default value in output Usage string // usage string for help output Required bool // whether the flag is required or not Hidden bool // whether to hide the flag in help output Default T // default value for this flag if not set by from any source Aliases []string // aliases that are allowed for this flag Validator func(T) error // custom function to validate this flag value QueryPath string // location in the request query string to put this flag's value HeaderPath string // location in the request header to put this flag's value BodyPath string // location in the request body to put this flag's value BodyRoot bool // if true, then use this value as the entire request body // contains filtered or unexported fields }
Flag [T] is a generic flag base which can be used to implement the most common interfaces used by urfave/cli. Additionally, it allows specifying where in an HTTP request the flag values should be placed (e.g. query, body, etc.).
func (Flag[T]) GetBodyPath ¶
func (*Flag[T]) GetCategory ¶
func (*Flag[T]) GetDefaultText ¶
func (*Flag[T]) GetEnvVars ¶
func (Flag[T]) GetHeaderPath ¶
func (Flag[T]) GetQueryPath ¶
func (Flag[T]) IsBodyRoot ¶
func (*Flag[T]) IsBoolFlag ¶
func (*Flag[T]) IsDefaultVisible ¶
func (*Flag[T]) IsMultiValueFlag ¶
func (*Flag[T]) IsRequired ¶
func (*Flag[T]) SetCategory ¶
func (*Flag[T]) SetInnerField ¶
func (*Flag[T]) TakesValue ¶
type HasOuterFlag ¶
type InRequest ¶
type InRequest interface {
GetQueryPath() string
GetHeaderPath() string
GetBodyPath() string
IsBodyRoot() bool
}
InRequest interface for flags that should be included in HTTP requests
type InnerFlag ¶
type InnerFlag[ T []any | []map[string]any | []DateTimeValue | []DateValue | []TimeValue | []string | []float64 | []int64 | []bool | any | map[string]any | DateTimeValue | DateValue | TimeValue | string | float64 | int64 | bool, ] struct { Name string // name of the flag DefaultText string // default text of the flag for usage purposes Usage string // usage string for help output Aliases []string // aliases that are allowed for this flag Validator func(T) error // custom function to validate this flag value OuterFlag cli.Flag // The flag on which this inner flag will set values InnerField string // The inner field which this flag will set }
InnerFlag[T] represents a CLI flag for the urfave/cli package that allows setting nested fields within other flags. For example, using `--foo.baz` will set the "baz" field on a parent flag named `--foo`.
func (*InnerFlag[T]) GetDefaultText ¶
func (*InnerFlag[T]) GetEnvVars ¶
func (*InnerFlag[T]) GetOuterFlag ¶
func (*InnerFlag[T]) IsBoolFlag ¶
func (*InnerFlag[T]) IsDefaultVisible ¶
func (*InnerFlag[T]) IsMultiValueFlag ¶
func (*InnerFlag[T]) SetOuterFlag ¶
func (*InnerFlag[T]) TakesValue ¶
type RequestContents ¶
The values that will be sent in different parts of a request.
func ExtractRequestContents ¶
func ExtractRequestContents(cmd *cli.Command) RequestContents
Extract query parameters, headers, and body values from command flags.
type SettableInnerField ¶
Allow setting inner fields on other flags (e.g. --foo.baz can set the "baz" field on the --foo flag)