command

package
v0.0.0-...-549b2e0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

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 PopRequestArgToFunc(req Request, name string, funcSet func(string) error)

func PopRequestArgs

func PopRequestArgs[
	VALUE interfaces.Stringer,
	VALUE_PTR interfaces.StringerSetterPtr[VALUE],
](
	req Request,
	name string,
) interfaces.Seq[VALUE_PTR]

func PrintSubcommandUsage

func PrintSubcommandUsage(flags flags.FlagSet)

TODO evaluate need

Types

type CLICompleter

type CLICompleter = cli.CLICompleter

type Cmd

type Cmd interface {
	Run(Request)
}

type CommandComponent

type CommandComponent interface {
	CommandComponentReader
	interfaces.CommandComponentWriter
}

type CommandComponentReader

type CommandComponentReader interface {
	GetCLIFlags() []string
}

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 CommandWithDescription

type CommandWithDescription interface {
	GetDescription() Description
}

type Completer

type Completer interface {
	Complete(Request, env_local.Env, CommandLineInput)
}

type Completion

type Completion struct {
	Value, Description string
}

type Config

type Config interface {
	interfaces.CommandComponentWriter
	GetConfigCLI() config_cli.Config
}

type Description

type Description struct {
	Short, Long string
}

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 Request

type Request struct {
	errors.Context
	Utility Utility
	FlagSet *flags.FlagSet
	// contains filtered or unexported fields
}

TODO refactor this to have a generic config field and for the commands_madder and commands_dodder packages to alias a concrete version for their own use

func (*Request) AssertNoMoreArgs

func (req *Request) AssertNoMoreArgs()

func (Request) LastArg

func (req Request) LastArg() (arg string, ok bool)

func (Request) PeekArgs

func (req Request) PeekArgs() collections_slice.String

TODO switch to ActiveContext

func (Request) PopArg

func (req Request) PopArg(name string) string

func (Request) PopArgOrDefault

func (req Request) PopArgOrDefault(name, defaultArg string) string

func (Request) PopArgs

func (req Request) PopArgs() []string

func (Request) PopArgsAsMutableSet

func (req Request) PopArgsAsMutableSet() collections_value.MutableSet[string]

func (Request) RemainingArgCount

func (req Request) RemainingArgCount() int

type SupportsCompletion

type SupportsCompletion interface {
	SupportsCompletion()
}

type Utility

type Utility struct {
	// contains filtered or unexported fields
}

func MakeUtility

func MakeUtility(name string, defaultConfig Config) Utility

func (Utility) AddCmd

func (utility Utility) AddCmd(name string, cmd Cmd)

func (Utility) AllCmds

func (utility Utility) AllCmds() interfaces.Seq2[string, Cmd]

func (Utility) GetCmd

func (utility Utility) GetCmd(name string) (Cmd, bool)

func (Utility) GetConfig

func (utility Utility) GetConfig() config_cli.Config

func (Utility) GetConfigAny

func (utility Utility) GetConfigAny() any

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) GetName

func (utility Utility) GetName() string

func (Utility) LenCmds

func (utility Utility) LenCmds() int

func (Utility) MakeCmdAndFlagSet

func (utility Utility) MakeCmdAndFlagSet(
	ctx errors.Context,
	args []string,
) (cmd Cmd, flagSet *flags.FlagSet, ok bool)

func (Utility) MakeRequest

func (utility Utility) MakeRequest(
	ctx errors.Context,
	cmd Cmd,
	flagSet *flags.FlagSet,
) (request Request, ok bool)

func (Utility) MergeUtility

func (utility Utility) MergeUtility(otherUtility Utility) Utility

func (Utility) MergeUtilityWithPrefix

func (utility Utility) MergeUtilityWithPrefix(
	otherUtility Utility,
	prefix string,
) Utility

func (Utility) PrintUsage

func (utility Utility) PrintUsage(ctx errors.Context, err error)

func (Utility) Run

func (utility Utility) Run(
	args []string,
)

Source Files

  • cmd.go
  • command_line_input.go
  • completion.go
  • flags.go
  • main.go
  • request.go
  • utility.go
  • utility_run.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL