Documentation
¶
Index ¶
- Constants
- func BuildCommandTree() (err error)
- func Errorf(format string, args ...interface{})
- func Initialize(w OutputWriter) (err error)
- func IsTerminalError(err error) (isTermErr bool)
- func Printf(format string, args ...interface{})
- func RegisterCommand(cmd Command, parents ...Command)
- func SetLogger(l *slog.Logger)
- func ShowCmdHelp(cmdName string) (err error)
- func ShowMainHelp() (err error)
- func ValidateCmds() (err error)
- func ValidateCommands() (err error)
- type ApprovalFunc
- type ApprovalResponse
- type ArgDef
- type CmdArgs
- type CmdBase
- func (c *CmdBase) AddParent(r reflect.Type)
- func (c *CmdBase) AddSubCommand(cmd Command)
- func (c *CmdBase) AssignArgs(args []string) (err error)
- func (c *CmdBase) DelegateTo() Command
- func (c *CmdBase) Description() string
- func (c *CmdBase) FlagSets() []*FlagSet
- func (c *CmdBase) FullNames() (names []string)
- func (c *CmdBase) Name() string
- func (c *CmdBase) ParentTypes() []reflect.Type
- func (c *CmdBase) ParseFlagSets(args []string, _ Config) (remainingArgs []string, err error)
- func (c *CmdBase) SetDelegateTo(cmd Command)
- func (c *CmdBase) Usage() string
- type CmdRunner
- type CmdRunnerArgs
- type Command
- type CommandHandler
- type Config
- type FlagDef
- type FlagSet
- type FlagType
- type GlobalFlagDefGetter
- type NULL
- type OutputWriter
- type ValidationFunc
Constants ¶
const ( NoResponse = 'n' YesResponse = 'y' AllResponse = 'a' DelayResponse = 'd' CancelResponse = 'c' )
Variables ¶
This section is empty.
Functions ¶
func BuildCommandTree ¶
func BuildCommandTree() (err error)
BuildCommandTree builds the command hierarchy from registrations This should be called by gmover.Initialize() after all init() functions complete
func Initialize ¶
func Initialize(w OutputWriter) (err error)
func IsTerminalError ¶
IsTerminalError checks if an error is related to terminal/input operations These errors should abort the entire operation rather than continue
func RegisterCommand ¶
RegisterCommand registers a command with optional parent type declarations First argument is the actual command, remaining arguments are parent type prototypes Example: RegisterCommand(&JobRunCmd{...}, &JobCmd{})
func ShowCmdHelp ¶
ShowCmdHelp displays help for a specific command
func ValidateCmds ¶
func ValidateCmds() (err error)
ValidateCmds ensures all registered commands have handlers
func ValidateCommands ¶
func ValidateCommands() (err error)
Types ¶
type ApprovalFunc ¶
type ApprovalFunc = func(context.Context, string) (ar ApprovalResponse, err error)
ApprovalFunc is called before moving each message Returns: approved (move this message), approveAll (auto-approve remaining), error Context allows cancellation via Ctrl-C
type ApprovalResponse ¶
type ApprovalResponse = byte
func PromptForApproval ¶
func PromptForApproval(ctx context.Context, prompt string) (ar ApprovalResponse, err error)
type ArgDef ¶
type ArgDef struct {
Name string
Usage string
Required bool
String *string // Where to assign the argument value
}
ArgDef defines a positional command argument
type CmdBase ¶
type CmdBase struct {
// contains filtered or unexported fields
}
CmdBase provides common functionality for all commands It implements the cliutil.Cmd interface
func (*CmdBase) AddSubCommand ¶
AddSubCommand returns the subcommands map
func (*CmdBase) AssignArgs ¶
AssignArgs assigns positional arguments to their defined config fields
func (*CmdBase) DelegateTo ¶
DelegateTo returns the command to delegate to, if any
func (*CmdBase) Description ¶
Description returns the command description with flag details
func (*CmdBase) ParentTypes ¶
func (*CmdBase) ParseFlagSets ¶
ParseFlagSets parses flags using the new FlagSet-based approach
func (*CmdBase) SetDelegateTo ¶
SetDelegateTo sets the command to delegate to
type CmdRunner ¶
type CmdRunner struct {
// contains filtered or unexported fields
}
func NewCmdRunner ¶
func NewCmdRunner(args CmdRunnerArgs) *CmdRunner
type CmdRunnerArgs ¶
type Command ¶
type Command interface {
Name() string
FullNames() []string
Usage() string
Description() string
AddSubCommand(Command)
DelegateTo() Command
AddParent(reflect.Type)
ParentTypes() []reflect.Type
FlagSets() []*FlagSet
ParseFlagSets([]string, Config) ([]string, error)
AssignArgs([]string) error
}
Command interface for basic command metadata and delegation
func GetDefaultCommand ¶
GetDefaultCommand retrieves a command or its default at any depth using dot notation
func GetExactCommand ¶
GetExactCommand retrieves a command at any depth using dot notation
func GetSubCmds ¶
GetSubCmds returns all subcommands for a given path
func GetTopLevelCmds ¶
func GetTopLevelCmds() []Command
GetTopLevelCmds returns all top-level commands sorted by name
type CommandHandler ¶
CommandHandler interface for commands that actually execute logic
type FlagDef ¶
type FlagDef struct {
Name string
Default any
Usage string
Required bool
Regex *regexp.Regexp
ValidationFunc ValidationFunc
String *string
Bool *bool
Int64 *int64
}
FlagDef defines a command flag declaratively
func (*FlagDef) ValidateValue ¶
ValidateValue validates the flag value using the defined validation rules
type FlagSet ¶
FlagSet combines a FlagSet with automatic config binding
type GlobalFlagDefGetter ¶
type GlobalFlagDefGetter interface {
GlobalFlagDefs() []FlagDef
}
type OutputWriter ¶
type OutputWriter interface {
Printf(format string, args ...interface{})
Errorf(format string, args ...interface{})
}
OutputWriter defines the interface for user-facing output
func NewOutputWriter ¶
func NewOutputWriter() OutputWriter
NewOutputWriter creates a console output writer
func SetOutput ¶
func SetOutput(writer OutputWriter) OutputWriter
SetOutput sets the global output writer (primarily for testing)
type ValidationFunc ¶
ValidationFunc validates a flag value and returns an error if invalid