Documentation
¶
Index ¶
- func PopRequestArg[VALUE interfaces.Stringer, VALUE_PTR interfaces.StringerSetterPtr[VALUE]](req Request, name string) VALUE_PTR
- func PopRequestArgTo(req Request, name string, value interfaces.StringerSetter)
- func PopRequestArgToFunc(req Request, name string, funcSet func(string) error)
- func PopRequestArgs[VALUE interfaces.Stringer, VALUE_PTR interfaces.StringerSetterPtr[VALUE]](req Request, name string) interfaces.Seq[VALUE_PTR]
- func PrintSubcommandUsage(flags flags.FlagSet)
- type Arg
- type ArgGroup
- type CLICompleter
- type Cmd
- type CommandComponent
- type CommandComponentReader
- type CommandLineInput
- type CommandWithArgs
- type CommandWithDescription
- type CommandWithMCPAnnotations
- type Completer
- type Completion
- type Config
- type Description
- type FlagValueCompleter
- type FuncCompleter
- type MCPAnnotations
- type Request
- func (req *Request) AssertNoMoreArgs()
- func (req Request) LastArg() (arg string, ok bool)
- func (req Request) PeekArgs() collections_slice.String
- func (req Request) PopArg(name string) string
- func (req Request) PopArgOrDefault(name, defaultArg string) string
- func (req Request) PopArgs() []string
- func (req Request) PopArgsAsMutableSet() collections_value.MutableSet[string]
- func (req Request) RemainingArgCount() int
- type SupportsCompletion
- type Utility
- func (utility Utility) AddCmd(name string, cmd Cmd)
- func (utility Utility) AllCmds() interfaces.Seq2[string, Cmd]
- func (utility Utility) GetCmd(name string) (Cmd, bool)
- func (utility Utility) GetConfig() config_cli.Config
- func (utility Utility) GetConfigAny() any
- func (utility Utility) GetName() string
- func (utility Utility) LenCmds() int
- func (utility Utility) MakeCmdAndFlagSet(ctx errors.Context, args []string) (cmd Cmd, flagSet *flags.FlagSet, ok bool)
- func (utility Utility) MakeRequest(ctx errors.Context, cmd Cmd, flagSet *flags.FlagSet) (request Request, ok bool)
- func (utility Utility) MergeUtility(otherUtility Utility) Utility
- func (utility Utility) MergeUtilityWithPrefix(otherUtility Utility, prefix string) Utility
- func (utility Utility) PrintUsage(ctx errors.Context, err error)
- func (utility Utility) Run(args []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PopRequestArg ¶
func PopRequestArg[ VALUE interfaces.Stringer, VALUE_PTR interfaces.StringerSetterPtr[VALUE], ](req Request, name string) VALUE_PTR
func PopRequestArgTo ¶
func PopRequestArgTo(req Request, name string, value interfaces.StringerSetter)
func PopRequestArgToFunc ¶
func PopRequestArgs ¶
func PopRequestArgs[ VALUE interfaces.Stringer, VALUE_PTR interfaces.StringerSetterPtr[VALUE], ]( req Request, name string, ) interfaces.Seq[VALUE_PTR]
Types ¶
type Arg ¶
type Arg struct {
// Name is used in synopsis, error messages, and as MCP schema property
// key. Should match the string passed to PopArg(name).
Name string
Description string
Required bool
// Variadic means this arg consumes all remaining positional arguments.
// At most one Arg per command may be Variadic, and it must be last.
Variadic bool
// EnumValues constrains the arg to listed values. Used for MCP schema
// enum and shell completion.
EnumValues []string
// Value carries type information for schema generation and future
// auto-parsing. Same interface flags use (StringerSetter). Nil means
// plain string. When non-nil, the concrete type determines the JSON
// schema type and Value.Set() provides validation.
Value interfaces.FlagValue
}
Arg declares metadata for a single positional argument. Mirrors the flag pattern: flagSet.Var(&cmd.RepoId, "repo", "usage") becomes Arg{Name: "repo-id", Value: &ids.RepoId{}, ...}
type ArgGroup ¶
type ArgGroup struct {
Name string // e.g. "query" (empty for inline groups)
Description string // group-level description for docs
Args []Arg
}
ArgGroup is a named set of args contributed by a command or component. Commands compose ArgGroups from their embedded components.
type CLICompleter ¶
type CLICompleter = cli.CLICompleter
type CommandComponent ¶
type CommandComponent interface {
CommandComponentReader
interfaces.CommandComponentWriter
}
type CommandLineInput ¶
type CommandLineInput struct {
FlagsOrArgs collections_slice.String
InProgress string
ContainsDoubleHyphen bool
Args collections_slice.String
Argi int
// contains filtered or unexported fields
}
TODO complete merging Args, consumed and FlagsOrArgs for use by Run/Complete
func (CommandLineInput) LastArg ¶
func (commandLine CommandLineInput) LastArg() (arg string, ok bool)
func (CommandLineInput) LastCompleteArg ¶
func (commandLine CommandLineInput) LastCompleteArg() (arg string, ok bool)
type CommandWithArgs ¶
type CommandWithArgs interface {
GetArgs() []ArgGroup
}
CommandWithArgs is the opt-in interface for declarative arg metadata. Commands that implement this get improved manpage SYNOPSIS/ARGUMENTS sections and auto-generated MCP schemas. Commands that don't continue to work as before.
type CommandWithDescription ¶
type CommandWithDescription interface {
GetDescription() Description
}
type CommandWithMCPAnnotations ¶
type CommandWithMCPAnnotations interface {
GetMCPAnnotations() MCPAnnotations
}
CommandWithMCPAnnotations lets commands declare their MCP hints.
type Completer ¶
type Completer interface {
Complete(Request, env_local.Env, CommandLineInput)
}
type Config ¶
type Config interface {
interfaces.CommandComponentWriter
GetConfigCLI() config_cli.Config
}
type FlagValueCompleter ¶
type FlagValueCompleter struct {
interfaces.FlagValue
FuncCompleter
}
func (FlagValueCompleter) Complete ¶
func (completer FlagValueCompleter) Complete( req Request, envLocal env_local.Env, commandLine CommandLineInput, )
func (FlagValueCompleter) String ¶
func (completer FlagValueCompleter) String() string
type FuncCompleter ¶
type FuncCompleter func(Request, env_local.Env, CommandLineInput)
type MCPAnnotations ¶
MCPAnnotations declares MCP tool hints without importing go-mcp protocol types, keeping the golf layer dependency-free.
type Request ¶
type Request struct {
errors.Context
Utility Utility
FlagSet *flags.FlagSet
// contains filtered or unexported fields
}
func (Request) PeekArgs ¶
func (req Request) PeekArgs() collections_slice.String
TODO switch to ActiveContext
func (Request) PopArgsAsMutableSet ¶
func (req Request) PopArgsAsMutableSet() collections_value.MutableSet[string]
type SupportsCompletion ¶
type SupportsCompletion interface {
SupportsCompletion()
}
type Utility ¶
type Utility struct {
// contains filtered or unexported fields
}
func (Utility) GetConfig ¶
func (utility Utility) GetConfig() config_cli.Config
func (Utility) GetConfigAny ¶
GetConfigAny returns the raw config as any, allowing callers to type-assert to their specific config type (e.g., repo_config_cli.Config for dodder commands).
func (Utility) MakeCmdAndFlagSet ¶
func (Utility) MakeRequest ¶
func (Utility) MergeUtilityWithPrefix ¶
Source Files
¶
- arg.go
- cmd.go
- command_line_input.go
- completion.go
- flags.go
- main.go
- request.go
- utility.go
- utility_run.go