Documentation ¶
Index ¶
- func CobraPopulator(root *cobra.Command, args []string) kflags.Populator
- func LogFlags(command *cobra.Command, log logger.Printer)
- func PopulateCommands(root *cobra.Command, args []string, resolvers ...kflags.Augmenter) error
- func PopulateDefaults(root *cobra.Command, args []string, resolvers ...kflags.Augmenter) error
- func PopulateFlagDefaults(root *cobra.Command, args []string, resolvers ...kflags.Augmenter) error
- func Run(root *cobra.Command, mods ...Modifier)
- type Command
- type FlagSet
- type Helper
- type HiddenFlagSet
- func (hfs *HiddenFlagSet) BoolVar(p *bool, name string, value bool, usage string)
- func (hfs *HiddenFlagSet) ByteFileVar(p *[]byte, name string, defaultFile string, usage string, ...)
- func (hfs *HiddenFlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string)
- func (hfs *HiddenFlagSet) Help(cmd *cobra.Command, args []string) bool
- func (hfs *HiddenFlagSet) Hide(name string)
- func (hfs *HiddenFlagSet) IntVar(p *int, name string, value int, usage string)
- func (hfs *HiddenFlagSet) StringArrayVar(p *[]string, name string, value []string, usage string)
- func (hfs *HiddenFlagSet) StringVar(p *string, name string, value string, usage string)
- type KCommand
- type Modifier
- type Modifiers
- type PFlag
- type Runnable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CobraPopulator ¶
CobraPopulator returns a kflags.Populator capable of filling in the defaults for flags defined through cobra and the pflags library.
func PopulateCommands ¶
func PopulateDefaults ¶
func PopulateFlagDefaults ¶
PopulateFlagDefaults is a function that walks all the flags of the specified root command and all its sub commands, the argv provided as args, and tries to provide defaults using the spcified resolvers.
root is the cobra.Command of which to walk the flags to fill in the defaults.
args is the list of command line parameters passed to the command, argv. This is generally os.Args. It is expected to include argv[0], the path of the command, as first argument.
resolvers is the list of resolvers to use to assign the defaults.
WARNING: PopulateFlagDefaults does not call Done() supplied list of resolvers. It is the responsibility of the caller to do so.
Types ¶
type HiddenFlagSet ¶
type HiddenFlagSet struct {
// contains filtered or unexported fields
}
func HideFlags ¶
func HideFlags(fs *FlagSet) *HiddenFlagSet
func (*HiddenFlagSet) BoolVar ¶
func (hfs *HiddenFlagSet) BoolVar(p *bool, name string, value bool, usage string)
func (*HiddenFlagSet) ByteFileVar ¶
func (hfs *HiddenFlagSet) ByteFileVar(p *[]byte, name string, defaultFile string, usage string, mods ...kflags.ByteFileModifier)
func (*HiddenFlagSet) DurationVar ¶
func (*HiddenFlagSet) Hide ¶
func (hfs *HiddenFlagSet) Hide(name string)
func (*HiddenFlagSet) IntVar ¶
func (hfs *HiddenFlagSet) IntVar(p *int, name string, value int, usage string)
func (*HiddenFlagSet) StringArrayVar ¶
func (hfs *HiddenFlagSet) StringArrayVar(p *[]string, name string, value []string, usage string)
type KCommand ¶
func (*KCommand) AddCommand ¶
func (kc *KCommand) AddCommand(def kflags.CommandDefinition, flags []kflags.FlagDefinition, action kflags.CommandAction) error
type Modifier ¶
func WithErrorHandler ¶
func WithErrorHandler(eh ...kflags.ErrorHandler) Modifier
WithErrorHandler sets a function that will be invoked for each error returned by the program. This is useful to allow to implement logic to handle specific errors in specific ways, or to augment the error message with more details.
func WithPrinter ¶
WithPrinter sets a function to use for logging.
func WithRunner ¶
Adds a function to run before the actual program. This is useful to perform - for example - additional initialization.