Documentation
¶
Index ¶
- Constants
- Variables
- func Apply(ctx context.Context, r *cobra.Command) error
- func ApplyCtx(ctx context.Context, me *Ctx, root *cobra.Command) error
- func Assemble(ctx context.Context) *cobra.Command
- func Bind(ctx context.Context, key any, value any) context.Context
- func BindG[T any](ctx context.Context, value T) context.Context
- func Build(ctx context.Context) (*cobra.Command, error)
- func BuildCtx(ctx context.Context, me *Ctx) (*cobra.Command, error)
- func ClearActiveCommand(ctx context.Context) context.Context
- func DecorateTemplate(ctx context.Context, root *cobra.Command, cfg *DecorateOptions) (string, error)
- func FormatCaller(path string, number int) string
- func FormatError(cmd *cobra.Command, err error) string
- func GetActiveCommand(ctx context.Context) string
- func GetAllNamedCommands(ctx context.Context) namedCommandMap
- func GetAlreadyBound[I any](ctx context.Context) (I, bool)
- func HandleErrorByPrintingToConsole(cmd *cobra.Command, err error) error
- func IsHandledByPrintingToConsole(err error) bool
- func MustNewCommand(ctx context.Context, name string, snk Snakeable) context.Context
- func NewArgument[I any](method Flagged)
- func NewCmd[I Cobrad](cmd I)
- func NewCommand(ctx context.Context, name string, snk Snakeable) (context.Context, error)
- func NewRootCommand(ctx context.Context, snk Snakeable) (context.Context, error)
- func NewWrappedEnum[I ~string](values ...I) *wrappedEnum[I]
- func RegisterBindingResolver[I any](ctx context.Context, res typedResolver[I], f ...flagbinding) context.Context
- func ResolveBindingsFromProvider(ctx context.Context, rf reflect.Value) (context.Context, error)
- func SetActiveCommand(ctx context.Context, str string) context.Context
- func SetNamedCommand(ctx context.Context, name string, cmd *NamedCommand) context.Context
- func SetRootCommand(ctx context.Context, cmd *NamedCommand) context.Context
- func WithActiveCommand(ctx context.Context, x func(*cobra.Command) error) error
- func WithNamedCommand(ctx context.Context, name string, x func(*cobra.Command) error) error
- func WithRootCommand(ctx context.Context, x func(*cobra.Command) error) error
- type Cobrad
- type Ctx
- type DecorateOptions
- type ErrHandledByPrintingToConsole
- type FMap
- type Flagged
- type HasRunArgs
- type IsRunnable
- type Method
- type NamedCommand
- type Snakeable
Constants ¶
View Source
const RootCommandName = "______root_____________"
Variables ¶
View Source
var ( ErrMissingBinding = errors.New("snake.ErrMissingBinding") ErrMissingRun = errors.New("snake.ErrMissingRun") ErrInvalidRun = errors.New("snake.ErrInvalidRun") ErrInvalidArguments = errors.New("snake.ErrInvalidArguments") ErrInvalidResolver = errors.New("snake.ErrInvalidResolver") )
View Source
var Defaults = []string{"context.Context", "*cobra.Command"}
View Source
var (
ErrInvalidMethodSignature = errors.New("invalid method signatured")
)
View Source
var (
ErrMissingResolver = errors.New("missing resolver")
)
Functions ¶
func ClearActiveCommand ¶ added in v0.10.1
func DecorateTemplate ¶ added in v0.10.4
func DecorateTemplate(ctx context.Context, root *cobra.Command, cfg *DecorateOptions) (string, error)
Init patches Cobra's usage template with configuration provided.
func FormatCaller ¶ added in v0.8.0
func GetActiveCommand ¶ added in v0.10.1
func GetAllNamedCommands ¶ added in v0.10.4
func HandleErrorByPrintingToConsole ¶ added in v0.8.1
func IsHandledByPrintingToConsole ¶ added in v0.8.1
func MustNewCommand ¶
func NewArgument ¶ added in v0.12.0
func NewCommand ¶
func NewRootCommand ¶
func NewWrappedEnum ¶ added in v0.12.0
func NewWrappedEnum[I ~string](values ...I) *wrappedEnum[I]
func RegisterBindingResolver ¶ added in v0.9.1
func ResolveBindingsFromProvider ¶ added in v0.9.0
func SetActiveCommand ¶ added in v0.10.1
func SetNamedCommand ¶ added in v0.10.1
func SetRootCommand ¶ added in v0.10.0
func SetRootCommand(ctx context.Context, cmd *NamedCommand) context.Context
func WithActiveCommand ¶ added in v0.10.1
func WithNamedCommand ¶ added in v0.10.1
Types ¶
type Ctx ¶ added in v0.12.0
type Ctx struct {
// contains filtered or unexported fields
}
func (*Ctx) FlagsForString ¶ added in v0.12.0
type DecorateOptions ¶ added in v0.4.0
type ErrHandledByPrintingToConsole ¶ added in v0.8.1
type ErrHandledByPrintingToConsole struct {
// contains filtered or unexported fields
}
func (*ErrHandledByPrintingToConsole) Error ¶ added in v0.8.1
func (e *ErrHandledByPrintingToConsole) Error() string
func (*ErrHandledByPrintingToConsole) Unwrap ¶ added in v0.8.1
func (e *ErrHandledByPrintingToConsole) Unwrap() error
type HasRunArgs ¶ added in v0.12.0
type IsRunnable ¶ added in v0.12.0
type Method ¶ added in v0.12.0
type Method interface {
Flags(*pflag.FlagSet)
Run() reflect.Value
RunArgs() []reflect.Type
ValidateResponse() error
HandleResponse([]reflect.Value) (*reflect.Value, error)
Name() string
Command() Cobrad
}
func NewCmdContext ¶ added in v0.12.0
type NamedCommand ¶ added in v0.11.0
type NamedCommand struct {
// contains filtered or unexported fields
}
func GetActiveNamedCommand ¶ added in v0.10.1
func GetActiveNamedCommand(ctx context.Context) *NamedCommand
func GetNamedCommand ¶ added in v0.10.1
func GetNamedCommand(ctx context.Context, name string) *NamedCommand
func GetRootCommand ¶ added in v0.10.0
func GetRootCommand(ctx context.Context) *NamedCommand
Source Files
¶
Click to show internal directories.
Click to hide internal directories.