Documentation
¶
Overview ¶
Package usages provides a mechanism to insert and recover richer usage information (eg whether a flag is required, whether it contains sensitive information) into and from a flag.Flag usage string, respectively.
Index ¶
- func Deprecated(usage string) string
- func DeprecatedAndSet(fs *flag.FlagSet) []string
- func FilterFlagSet(fs *flag.FlagSet, fn FlagSetFilterFn) []string
- func IsDeprecated(f *flag.Flag) bool
- func IsRequired(f *flag.Flag) bool
- func IsSensitive(f *flag.Flag) bool
- func MissingRequired(fs *flag.FlagSet) []string
- func Required(usage string) string
- func Sensitive(usage string) string
- type FlagSetFilterFn
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deprecated ¶
Deprecated produces an encoded usage string for a Flag indiciating that the Flag is deprecated. It can be passed through usage.New() to recover the full Usage.
func DeprecatedAndSet ¶
DeprecatedAndSet produces a slice of the names of all flags for which the Usage string indiciates deprecation but are set
func FilterFlagSet ¶
func FilterFlagSet(fs *flag.FlagSet, fn FlagSetFilterFn) []string
FilterFlagSet produces a slice of the names of flags for which the given FilterFn returns true
func IsDeprecated ¶
IsDeprecated checks the usage string of the given Flag to see if it is marked as deprecated.
func IsRequired ¶
IsRequired checks the usage string of the given Flag to see if it is marked as required.
func IsSensitive ¶
IsSensitive checks the usage string of the given Flag to see if it is marked as sensitive.
func MissingRequired ¶
MissingRequired produces a slice of the names of all flags for which the Usage string indiciates requiredness but no value is set.
Types ¶
type FlagSetFilterFn ¶
FlagSetFilterFn is a predicate function that takes a flag and whether or not the flag is set as its input.
type Usage ¶
type Usage interface { // Usage returns the original usage string, without any decoration Usage() string // IsRequired returns true if the flag has been marked as required IsRequired() bool // IsSensitive returns true if the flag has been marked as containing // sensitive information that should't be dispayed. IsSensitive() bool // IsDeprecated returns true if the flag has been marked as deprecated IsDeprecated() bool // SetRequired marks the flag as required SetRequired() Usage // SetSensitive marks the flag as containing sensitive information that // should't be dispayed. SetSensitive() Usage // SetDeprecated marks the flag as deprecated SetDeprecated() Usage // Pretty() returns a human-friendly usage string, decorated with an // indication of whether the flag has been marked as required or sensitive Pretty() string // String() returns an encoded string that can be passed to New() to recover // the full state of the Usage later. String() string }
Usage represents richer usage information for a flag.Flag