Documentation
¶
Index ¶
- func Annotation(key, value string) opt.Option[Command]
- func Annotations(annotations map[string]string) opt.Option[Command]
- func BoolFlag(flag Flag, ptr *bool) opt.Option[Command]
- func Commands(commandProviders ...any) opt.Option[app.Module]
- func Deprecated(reason ...string) opt.Option[Command]
- func Do(impl func(ctx context.Context) error) opt.Option[Command]
- func Example(example string) opt.Option[Command]
- func IntFlag(flag Flag, ptr *int) opt.Option[Command]
- func Module() app.Module
- func Runner(impl func(cmd *cobra.Command, args []string) error) opt.Option[Command]
- func StringFlag(flag Flag, ptr *string) opt.Option[Command]
- func StringsFlag(flag Flag, ptr *[]string) opt.Option[Command]
- func SuggestFor(alternatives ...string) opt.Option[Command]
- type Command
- type Flag
- type Root
- type RootParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Annotation ¶ added in v0.3.0
Annotation sets a key-value pair in the Annotations map of a Command.
func Annotations ¶ added in v0.3.0
Annotations sets additional metadata for the command via the provided annotations map.
func BoolFlag ¶ added in v0.4.8
BoolFlag creates an option for a boolean flag within a Cobra command and links it to a specified bool pointer.
func Deprecated ¶ added in v0.3.0
Deprecated marks a Command as deprecated optionally specifying a reason.
func IntFlag ¶ added in v0.4.8
IntFlag registers an integer flag with the given flag specifications and stores the value in the specified pointer.
func Runner ¶ added in v0.3.0
Runner is where your actual command code should go. Deprecated: use command.Do instead
func StringFlag ¶ added in v0.3.0
StringFlag configures a string flag for a command using the provided Flag configuration and a pointer to store the flag's value.
func StringsFlag ¶ added in v0.5.0
StringsFlag registers a string slice command-line flag for the given Command.
Types ¶
type Command ¶
type Command struct {
Name string
Short string
Long string
Run func(cmd *cobra.Command, args []string) error
Example string
Annotations map[string]string
Deprecated string
SuggestFor []string
MutuallyExclusiveFlags []string
RequiredOneFlags []string
RequiredFlags []string
FlagHandlers map[string]func(cmd *cobra.Command) error
ChildOf []string
}
type Flag ¶ added in v0.3.0
type Flag struct {
// Name is the identifier for the command-line option.
Name string
// Shorthand is a single-character alias for the flag that allows for quicker command-line access.
Shorthand string
// Usage describes the purpose or functionality of the command-line flag.
Usage string
// OneRequired indicates that at least one of the flags marked with this field must be specified.
OneRequired bool
// Required indicates whether this flag is mandatory for the command-line tool to execute successfully.
Required bool
// Exclusive indicates whether the flag is mutually exclusive with other flags in the command-line tool.
Exclusive bool
}
Flag represents a command-line option for a CLI application.
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
func NewRoot ¶
func NewRoot(params RootParams) (*Root, error)