Cleanup: Collapse flag interfaces
This commit is contained in:
@@ -64,8 +64,8 @@ GLOBAL OPTIONS:
|
||||
COPYRIGHT:
|
||||
{{wrap .Copyright 3}}{{end}}
|
||||
`
|
||||
AppHelpTemplate is the text template for the Default help topic. cli.go uses
|
||||
text/template to render templates. You can render custom help text by
|
||||
AppHelpTemplate is the text template for the Default help topic. cli.go
|
||||
uses text/template to render templates. You can render custom help text by
|
||||
setting this variable.
|
||||
|
||||
var CommandHelpTemplate = `NAME:
|
||||
@@ -201,9 +201,9 @@ func DefaultAppComplete(cCtx *Context)
|
||||
func DefaultCompleteWithFlags(cmd *Command) func(cCtx *Context)
|
||||
func FlagNames(name string, aliases []string) []string
|
||||
func HandleAction(action interface{}, cCtx *Context) (err error)
|
||||
HandleAction attempts to figure out which Action signature was used. If it's
|
||||
an ActionFunc or a func with the legacy signature for Action, the func is
|
||||
run!
|
||||
HandleAction attempts to figure out which Action signature was used.
|
||||
If it's an ActionFunc or a func with the legacy signature for Action,
|
||||
the func is run!
|
||||
|
||||
func HandleExitCoder(err error)
|
||||
HandleExitCoder handles errors implementing ExitCoder by printing their
|
||||
@@ -360,14 +360,14 @@ func (a *App) RunAsSubcommand(ctx *Context) (err error)
|
||||
to generate command-specific flags
|
||||
|
||||
func (a *App) RunContext(ctx context.Context, arguments []string) (err error)
|
||||
RunContext is like Run except it takes a Context that will be passed to its
|
||||
commands and sub-commands. Through this, you can propagate timeouts and
|
||||
RunContext is like Run except it takes a Context that will be passed to
|
||||
its commands and sub-commands. Through this, you can propagate timeouts and
|
||||
cancellation requests
|
||||
|
||||
func (a *App) Setup()
|
||||
Setup runs initialization code to ensure all data structures are ready for
|
||||
`Run` or inspection prior to `Run`. It is internally called by `Run`, but
|
||||
will return early if setup has already happened.
|
||||
Setup runs initialization code to ensure all data structures are ready
|
||||
for `Run` or inspection prior to `Run`. It is internally called by `Run`,
|
||||
but will return early if setup has already happened.
|
||||
|
||||
func (a *App) ToFishCompletion() (string, error)
|
||||
ToFishCompletion creates a fish completion string for the `*App` The
|
||||
@@ -460,7 +460,7 @@ func (f *BoolFlag) Get(ctx *Context) bool
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *BoolFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *BoolFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -491,12 +491,10 @@ func (f *BoolFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *BoolFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type CategorizableFlag interface {
|
||||
VisibleFlag
|
||||
|
||||
GetCategory() string
|
||||
}
|
||||
CategorizableFlag is an interface that allows us to potentially use a flag
|
||||
in a categorized representation.
|
||||
@@ -707,18 +705,12 @@ type DocGenerationFlag interface {
|
||||
// TakesValue returns true if the flag takes a value, otherwise false
|
||||
TakesValue() bool
|
||||
|
||||
// GetUsage returns the usage string for the flag
|
||||
GetUsage() string
|
||||
|
||||
// GetValue returns the flags value as string representation and an empty
|
||||
// string if the flag takes no value at all.
|
||||
GetValue() string
|
||||
|
||||
// GetDefaultText returns the default text for this flag
|
||||
GetDefaultText() string
|
||||
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
GetEnvVars() []string
|
||||
}
|
||||
DocGenerationFlag is an interface that allows documentation generation for
|
||||
the flag
|
||||
@@ -750,7 +742,7 @@ func (f *DurationFlag) Get(ctx *Context) time.Duration
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *DurationFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *DurationFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -781,7 +773,7 @@ func (f *DurationFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *DurationFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type ErrorFormatter interface {
|
||||
Format(s fmt.State, verb rune)
|
||||
@@ -799,9 +791,9 @@ func Exit(message interface{}, exitCode int) ExitCoder
|
||||
Exit wraps a message and exit code into an error, which by default is
|
||||
handled with a call to os.Exit during default error handling.
|
||||
|
||||
This is the simplest way to trigger a non-zero exit code for an App without
|
||||
having to call os.Exit manually. During testing, this behavior can be
|
||||
avoided by overiding the ExitErrHandler function on an App or the
|
||||
This is the simplest way to trigger a non-zero exit code for an App
|
||||
without having to call os.Exit manually. During testing, this behavior
|
||||
can be avoided by overiding the ExitErrHandler function on an App or the
|
||||
package-global OsExiter function.
|
||||
|
||||
func NewExitError(message interface{}, exitCode int) ExitCoder
|
||||
@@ -820,6 +812,14 @@ type Flag interface {
|
||||
Apply(*flag.FlagSet) error
|
||||
Names() []string
|
||||
IsSet() bool
|
||||
IsRequired() bool
|
||||
// IsVisible returns true if the flag is not hidden, otherwise false
|
||||
IsVisible() bool
|
||||
GetCategory() string
|
||||
// GetUsage returns the usage string for the flag
|
||||
GetUsage() string
|
||||
// GetEnvVars returns the env vars for this flag
|
||||
GetEnvVars() []string
|
||||
}
|
||||
Flag is a common interface related to parsing flags in cli. For more
|
||||
advanced flag parsing techniques, it is recommended that this interface be
|
||||
@@ -923,7 +923,7 @@ func (f *Float64Flag) Get(ctx *Context) float64
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *Float64Flag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *Float64Flag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -954,7 +954,7 @@ func (f *Float64Flag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *Float64Flag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type Float64Slice struct {
|
||||
// Has unexported fields.
|
||||
@@ -1006,7 +1006,7 @@ func (f *Float64SliceFlag) Get(ctx *Context) []float64
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *Float64SliceFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *Float64SliceFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1081,7 +1081,7 @@ func (f *GenericFlag) Get(ctx *Context) interface{}
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *GenericFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *GenericFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1112,7 +1112,7 @@ func (f *GenericFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *GenericFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type Int64Flag struct {
|
||||
Name string
|
||||
@@ -1141,7 +1141,7 @@ func (f *Int64Flag) Get(ctx *Context) int64
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *Int64Flag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *Int64Flag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1172,7 +1172,7 @@ func (f *Int64Flag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *Int64Flag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type Int64Slice struct {
|
||||
// Has unexported fields.
|
||||
@@ -1224,7 +1224,7 @@ func (f *Int64SliceFlag) Get(ctx *Context) []int64
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *Int64SliceFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *Int64SliceFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1261,7 +1261,7 @@ func (f *Int64SliceFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *Int64SliceFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type IntFlag struct {
|
||||
Name string
|
||||
@@ -1290,7 +1290,7 @@ func (f *IntFlag) Get(ctx *Context) int
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *IntFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *IntFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1321,7 +1321,7 @@ func (f *IntFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *IntFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type IntSlice struct {
|
||||
// Has unexported fields.
|
||||
@@ -1377,7 +1377,7 @@ func (f *IntSliceFlag) Get(ctx *Context) []int
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *IntSliceFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *IntSliceFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1414,7 +1414,7 @@ func (f *IntSliceFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *IntSliceFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type MultiError interface {
|
||||
error
|
||||
@@ -1431,8 +1431,8 @@ type MultiInt64Flag = SliceFlag[*Int64SliceFlag, []int64, int64]
|
||||
directly, as Value and/or Destination. See also SliceFlag.
|
||||
|
||||
type MultiIntFlag = SliceFlag[*IntSliceFlag, []int, int]
|
||||
MultiIntFlag extends IntSliceFlag with support for using slices directly, as
|
||||
Value and/or Destination. See also SliceFlag.
|
||||
MultiIntFlag extends IntSliceFlag with support for using slices directly,
|
||||
as Value and/or Destination. See also SliceFlag.
|
||||
|
||||
type MultiStringFlag = SliceFlag[*StringSliceFlag, []string, string]
|
||||
MultiStringFlag extends StringSliceFlag with support for using slices
|
||||
@@ -1475,7 +1475,7 @@ func (f *PathFlag) Get(ctx *Context) string
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *PathFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *PathFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1506,15 +1506,13 @@ func (f *PathFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *PathFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type RequiredFlag interface {
|
||||
Flag
|
||||
|
||||
IsRequired() bool
|
||||
}
|
||||
RequiredFlag is an interface that allows us to mark flags as required it
|
||||
allows flags required flags to be backwards compatible with the Flag
|
||||
RequiredFlag is an interface that allows us to mark flags as required
|
||||
it allows flags required flags to be backwards compatible with the Flag
|
||||
interface
|
||||
|
||||
type Serializer interface {
|
||||
@@ -1527,9 +1525,9 @@ type SliceFlag[T SliceFlagTarget[E], S ~[]E, E any] struct {
|
||||
Value S
|
||||
Destination *S
|
||||
}
|
||||
SliceFlag extends implementations like StringSliceFlag and IntSliceFlag with
|
||||
support for using slices directly, as Value and/or Destination. See also
|
||||
SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag,
|
||||
SliceFlag extends implementations like StringSliceFlag and IntSliceFlag
|
||||
with support for using slices directly, as Value and/or Destination.
|
||||
See also SliceFlagTarget, MultiStringFlag, MultiFloat64Flag, MultiInt64Flag,
|
||||
MultiIntFlag.
|
||||
|
||||
func (x *SliceFlag[T, S, E]) Apply(set *flag.FlagSet) error
|
||||
@@ -1564,9 +1562,7 @@ func (x *SliceFlag[T, S, E]) TakesValue() bool
|
||||
|
||||
type SliceFlagTarget[E any] interface {
|
||||
Flag
|
||||
RequiredFlag
|
||||
DocGenerationFlag
|
||||
VisibleFlag
|
||||
CategorizableFlag
|
||||
|
||||
// SetValue should propagate the given slice to the target, ideally as a new value.
|
||||
@@ -1612,7 +1608,7 @@ func (f *StringFlag) Get(ctx *Context) string
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *StringFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *StringFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1643,7 +1639,7 @@ func (f *StringFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *StringFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type StringSlice struct {
|
||||
// Has unexported fields.
|
||||
@@ -1697,7 +1693,7 @@ func (f *StringSliceFlag) Get(ctx *Context) []string
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *StringSliceFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *StringSliceFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1734,7 +1730,7 @@ func (f *StringSliceFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *StringSliceFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type SuggestCommandFunc func(commands []*Command, provided string) string
|
||||
|
||||
@@ -1800,7 +1796,7 @@ func (f *TimestampFlag) Get(ctx *Context) *time.Time
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *TimestampFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *TimestampFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1831,7 +1827,7 @@ func (f *TimestampFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *TimestampFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type Uint64Flag struct {
|
||||
Name string
|
||||
@@ -1860,7 +1856,7 @@ func (f *Uint64Flag) Get(ctx *Context) uint64
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *Uint64Flag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *Uint64Flag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1891,7 +1887,7 @@ func (f *Uint64Flag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *Uint64Flag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type UintFlag struct {
|
||||
Name string
|
||||
@@ -1920,7 +1916,7 @@ func (f *UintFlag) Get(ctx *Context) uint
|
||||
Get returns the flag’s value in the given Context.
|
||||
|
||||
func (f *UintFlag) GetCategory() string
|
||||
GetCategory returns the category for the flag
|
||||
GetCategory returns the category of the flag
|
||||
|
||||
func (f *UintFlag) GetDefaultText() string
|
||||
GetDefaultText returns the default text for this flag
|
||||
@@ -1951,13 +1947,10 @@ func (f *UintFlag) String() string
|
||||
String returns a readable representation of this value (for usage defaults)
|
||||
|
||||
func (f *UintFlag) TakesValue() bool
|
||||
TakesValue returns true of the flag takes a value, otherwise false
|
||||
TakesValue returns true if the flag takes a value, otherwise false
|
||||
|
||||
type VisibleFlag interface {
|
||||
Flag
|
||||
|
||||
// IsVisible returns true if the flag is not hidden, otherwise false
|
||||
IsVisible() bool
|
||||
}
|
||||
VisibleFlag is an interface that allows to check if a flag is visible
|
||||
|
||||
@@ -1986,9 +1979,9 @@ func InitInputSource(flags []cli.Flag, createInputSource func() (InputSourceCont
|
||||
that are supported by the input source
|
||||
|
||||
func InitInputSourceWithContext(flags []cli.Flag, createInputSource func(cCtx *cli.Context) (InputSourceContext, error)) cli.BeforeFunc
|
||||
InitInputSourceWithContext is used to to setup an InputSourceContext on a
|
||||
cli.Command Before method. It will create a new input source based on the
|
||||
func provided with potentially using existing cli.Context values to
|
||||
InitInputSourceWithContext is used to to setup an InputSourceContext on
|
||||
a cli.Command Before method. It will create a new input source based on
|
||||
the func provided with potentially using existing cli.Context values to
|
||||
initialize itself. If there is no error it will then apply the new input
|
||||
source to any flags that are supported by the input source
|
||||
|
||||
|
Reference in New Issue
Block a user