Remove all flag interfaces

This commit is contained in:
Naveen Gogineni
2022-09-04 22:51:05 -04:00
parent ab68d8a69d
commit 268cb973f8
28 changed files with 192 additions and 262 deletions

View File

@@ -493,12 +493,6 @@ func (f *BoolFlag) String() string
func (f *BoolFlag) TakesValue() bool
TakesValue returns true if the flag takes a value, otherwise false
type CategorizableFlag interface {
VisibleFlag
}
CategorizableFlag is an interface that allows us to potentially use a flag
in a categorized representation.
type Command struct {
// The name of the command
Name string
@@ -699,22 +693,6 @@ func (cCtx *Context) Uint64(name string) uint64
func (cCtx *Context) Value(name string) interface{}
Value returns the value of the flag corresponding to `name`
type DocGenerationFlag interface {
Flag
// TakesValue returns true if the flag takes a value, otherwise false
TakesValue() bool
// 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
}
DocGenerationFlag is an interface that allows documentation generation for
the flag
type DurationFlag struct {
Name string
@@ -820,6 +798,13 @@ type Flag interface {
GetUsage() string
// GetEnvVars returns the env vars for this flag
GetEnvVars() []string
// TakesValue returns true if the flag takes a value, otherwise false
TakesValue() bool
// GetDefaultText returns the default text for this flag
GetDefaultText() string
// GetValue returns the flags value as string representation and an empty
// string if the flag takes no value at all.
GetValue() 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
@@ -1508,13 +1493,6 @@ func (f *PathFlag) String() string
func (f *PathFlag) TakesValue() bool
TakesValue returns true if the flag takes a value, otherwise false
type RequiredFlag interface {
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 {
Serialize() string
}
@@ -1562,8 +1540,6 @@ func (x *SliceFlag[T, S, E]) TakesValue() bool
type SliceFlagTarget[E any] interface {
Flag
DocGenerationFlag
CategorizableFlag
// SetValue should propagate the given slice to the target, ideally as a new value.
// Note that a nil slice should nil/clear any existing value (modelled as ~[]E).
@@ -1949,16 +1925,11 @@ func (f *UintFlag) String() string
func (f *UintFlag) TakesValue() bool
TakesValue returns true if the flag takes a value, otherwise false
type VisibleFlag interface {
Flag
}
VisibleFlag is an interface that allows to check if a flag is visible
type VisibleFlagCategory interface {
// Name returns the category name string
Name() string
// Flags returns a slice of VisibleFlag sorted by name
Flags() []VisibleFlag
Flags() []Flag
}
VisibleFlagCategory is a category containing flags.