Documentation ¶
Index ¶
- type Command
- func (c *Command) AddCommand(commands ...*Command)
- func (c *Command) BindEnv(input ...string) error
- func (c *Command) BindFlag(key string) error
- func (c *Command) BindFlags() error
- func (c *Command) BindInheritedFlag(key string) error
- func (c *Command) BindInheritedFlags() error
- func (c *Command) BindLocalFlag(key string) error
- func (c *Command) BindLocalFlags() error
- func (c *Command) BindLocalNonPersistentFlag(key string) error
- func (c *Command) BindLocalNonPersistentFlags() error
- func (c *Command) BindNonInheritedFlag(key string) error
- func (c *Command) BindNonInheritedFlags() error
- func (c *Command) BindPersistentFlag(key string) error
- func (c *Command) BindPersistentFlags() error
- func (c *Command) Commands() []*Command
- func (c *Command) Execute() error
- func (c *Command) ExecuteC() (cmd *cobra.Command, err error)
- func (c *Command) ExecuteContext(ctx context.Context) error
- func (c *Command) ExecuteContextC(ctx context.Context) (*cobra.Command, error)
- func (c *Command) Fs() afero.Fs
- func (c *Command) PrintOut(i ...interface{})
- func (c *Command) PrintOutf(format string, i ...interface{})
- func (c *Command) PrintOutln(i ...interface{})
- func (c *Command) ReadFileOrStdIn(fileFlag string) (io.ReadCloser, error)
- func (c *Command) RemoveCommand(cmds ...*Command)
- func (c *Command) ResetCommands()
- func (c *Command) Root() *Command
- func (c *Command) Viper() *viper.Viper
- func (c *Command) WalkCommands(fn func(*Command))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { *cobra.Command D *log.Logger V *log.Logger UseConfigFile bool UseEnv bool UseDebugLogging bool AutomaticBindViper bool // PersistentPreRun: children of this command will inherit and execute. PersistentPreRun func(cmd *Command, args []string) // PersistentPreRunE: PersistentPreRun but returns an error. PersistentPreRunE func(cmd *Command, args []string) error // PreRun: children of this command will not inherit. PreRun func(cmd *Command, args []string) // PreRunE: PreRun but returns an error. PreRunE func(cmd *Command, args []string) error // Run: Typically the actual work function. Most commands will only implement this. Run func(cmd *Command, args []string) // RunE: Run but returns an error. RunE func(cmd *Command, args []string) error // PostRun: run after the Run command. PostRun func(cmd *Command, args []string) // PostRunE: PostRun but returns an error. PostRunE func(cmd *Command, args []string) error // PersistentPostRun: children of this command will inherit and execute after PostRun. PersistentPostRun func(cmd *Command, args []string) // PersistentPostRunE: PersistentPostRun but returns an error. PersistentPostRunE func(cmd *Command, args []string) error // contains filtered or unexported fields }
Command is a wrapper around cobra.Command that adds some additional functionality.
func NewCommand ¶
NewCommand creates a new Command.
func (*Command) AddCommand ¶
AddCommand adds a command to the command.
func (*Command) BindInheritedFlag ¶
BindInheritedFlag binds a flag inherited from a parent command to a viper key.
func (*Command) BindInheritedFlags ¶
BindInheritedFlags binds all flags inherited from a parent command to viper.
func (*Command) BindLocalFlag ¶
BindLocalFlag binds a local flag to a viper key.
func (*Command) BindLocalFlags ¶
BindLocalFlags binds all local flags to viper.
func (*Command) BindLocalNonPersistentFlag ¶
BindLocalNonPersistentFlag binds a flag specific only to this to a viper key.
func (*Command) BindLocalNonPersistentFlags ¶
BindLocalNonPersistentFlags binds all flags specific to only this command to viper.
func (*Command) BindNonInheritedFlag ¶
BindNonInheritedFlag binds a flag which were not inherited from parent commands to a viper key.
func (*Command) BindNonInheritedFlags ¶
BindNonInheritedFlags binds all flags which were not inherited from parent commands to viper.
func (*Command) BindPersistentFlag ¶
BindPersistentFlag binds a persistent flag to a viper key.
func (*Command) BindPersistentFlags ¶
BindPersistentFlags binds all persistent flags to viper.
func (*Command) ExecuteContext ¶
ExecuteContext is a wrapper around cobra.Command.ExecuteContext.
func (*Command) ExecuteContextC ¶
ExecuteContextC is a wrapper around cobra.Command.ExecuteContextC.
func (*Command) PrintOut ¶
func (c *Command) PrintOut(i ...interface{})
PrintOut is a convenience method to Print to the defined output, fallback to Stdout if not set.
func (*Command) PrintOutf ¶
PrintOutf is a convenience method to Printf to the defined output, fallback to Stdout if not set.
func (*Command) PrintOutln ¶
func (c *Command) PrintOutln(i ...interface{})
PrintOutln is a convenience method to Println to the defined output, fallback to Stdout if not set.
func (*Command) ReadFileOrStdIn ¶
func (c *Command) ReadFileOrStdIn(fileFlag string) (io.ReadCloser, error)
ReadFileOrStdIn returns io.ReadCloser. If a file is specified, it is opened and returned. Otherwise, stdin is returned. When a file is returned, it must be closed by the caller.
func (*Command) RemoveCommand ¶
func (*Command) ResetCommands ¶
func (c *Command) ResetCommands()