Documentation
¶
Index ¶
- func ErrInvalidArgs(msg string) error
- func MergeStructuredParams(flags map[string]any, explicit map[string]any) (map[string]any, error)
- type CommandRouter
- func (r *CommandRouter) Build(executor func(*ParsedCommand) error) error
- func (r *CommandRouter) CurrentInput() *frameworkadapter.RawInput
- func (r *CommandRouter) Execute(input *frameworkadapter.RawInput, executor func(*ParsedCommand) error) error
- func (r *CommandRouter) RootCommand() *cobra.Command
- func (r *CommandRouter) Route(input *frameworkadapter.RawInput) (*ParsedCommand, error)
- type ParsedCommand
- type RouteDiagnostic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrInvalidArgs ¶
ErrInvalidArgs returns a user-category CLIError for invalid argument input. It is provided here so that callers (e.g. cliapp) do not need to import the full errors package just to construct a simple user error.
func MergeStructuredParams ¶
MergeStructuredParams folds --params (JSON) and --set (key=value) into the flag set. Keys already present in explicit (i.e. the user passed a real CLI flag) take precedence and are left untouched.
Keys contributed by --params and --set are promoted into explicit so downstream steps that filter by ExplicitFlags treat them the same as a user-typed CLI flag.
explicit is mutated in place; callers should pass the same map they intend to use as ParsedCommand.ExplicitFlags.
Types ¶
type CommandRouter ¶
type CommandRouter struct {
// contains filtered or unexported fields
}
func NewCommandRouter ¶
func NewCommandRouter(manager *registry.RegistryManager, appName string) (*CommandRouter, error)
func (*CommandRouter) Build ¶
func (r *CommandRouter) Build(executor func(*ParsedCommand) error) error
func (*CommandRouter) CurrentInput ¶
func (r *CommandRouter) CurrentInput() *frameworkadapter.RawInput
func (*CommandRouter) Execute ¶
func (r *CommandRouter) Execute(input *frameworkadapter.RawInput, executor func(*ParsedCommand) error) error
func (*CommandRouter) RootCommand ¶
func (r *CommandRouter) RootCommand() *cobra.Command
func (*CommandRouter) Route ¶
func (r *CommandRouter) Route(input *frameworkadapter.RawInput) (*ParsedCommand, error)
type ParsedCommand ¶
type ParsedCommand struct {
Node *registry.CommandNode
FullPath []string
Flags map[string]any
ExplicitFlags map[string]any
Args []string
IsHelp bool
RawArgs []string
RawFlags map[string]string
Diagnostics []RouteDiagnostic
}
func ParseInput ¶
func ParseInput(reg *registry.Registry, input *frameworkadapter.RawInput) (*ParsedCommand, error)
ParseInput converts RawInput to ParsedCommand by resolving the command and parsing parameters. This is a helper function primarily used in tests and for programmatic command construction.
NOTE: In production CLI flows, parameter parsing is handled by cobra. This function is mainly for SDK/programmatic access and test scenarios.