Documentation
¶
Index ¶
- func Execute(cmd *cobra.Command) error
- func FlagsGetString(flags *pflag.FlagSet, name, defaults string) (out string)
- func ResetBoolOnExecute(flag *pflag.Flag, target *bool, defaultValue func() bool)
- func ResetStringOnExecute(flag *pflag.Flag, target *string, defaultValue func() string)
- func ResetStringSliceOnExecute(flag *pflag.Flag, target *[]string, defaultValue func() []string)
- type Commander
- type Helper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
Execute resets opted-in flags before Cobra parses arguments. It restores each command's original SilenceErrors setting after execution, even on panic. Passing a child command executes and restores its entire root tree.
func FlagsGetString ¶
FlagsGetString reads string value from flags and returns it, if error => returns defaults.
func ResetBoolOnExecute ¶
ResetBoolOnExecute marks a local flag registered with BoolVarP to read its default again before every Execute.
func ResetStringOnExecute ¶
ResetStringOnExecute marks a local flag registered with StringVarP to read its default again before every Execute.
Types ¶
type Commander ¶
Commander represents valid cobra.Command command.
type Helper ¶
type Helper struct {
// UserConfigDir returns user's config directory see also: [os.UserConfigDir]
UserConfigDir func() (string, error)
}
Helper provides different system functions over one entrypoint (i.e. this helper) You can override functions for testing applicable assets.
func (*Helper) WithUserConfigDir ¶
WithUserConfigDir sets os.UserConfigDir compatible function for tests.