Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmder ¶
type Cmder struct {
// contains filtered or unexported fields
}
func NewCmder ¶
func NewCmder(cfg any, onFinalize OnFinalizeFunc, opts ...CmderOption) (*Cmder, error)
NewCmder creates a new Cmder instance. It takes a config struct, a callback function when the command is finalized and a variadic list of options.
type CmderOption ¶
type CmderOption func(*Cmder)
func WithConfigFile ¶
func WithConfigFile(file string) CmderOption
WithConfigFile sets the config file to use for the command. explicitly defines the path, name and extension of the config file.
func WithFS ¶
func WithFS(fs afero.Fs) CmderOption
WithFS sets the filesystem to use for the command. This is useful for testing.
func WithLongDesc ¶
func WithLongDesc(long string) CmderOption
WithLongDesc sets the long description for the command. This is used by the "help" command.
func WithPrefix ¶
func WithPrefix(prefix string) CmderOption
WithPrefix sets the prefix for environment variables. For example, if the prefix is "APP", then the environment variable "APP_DEBUG" will be used to set the value of the flag "--debug".
func WithShortDesc ¶
func WithShortDesc(short string) CmderOption
WithShortDesc sets the short description for the command. This is used by the "help" command.
func WithVersion ¶
func WithVersion(version string) CmderOption
WithVersion sets the version string for the command. This is used by the "version" command.
type OnFinalizeFunc ¶
type OnFinalizeFunc func(cfg any)