Versions in this module Expand all Collapse all v1 v1.0.0 Oct 1, 2026 Changes in this version + var ErrInternal = errors.New("internal error") + var ErrInterrupted = errors.New("interrupted") + var ErrNotInteractive = UsageError(errors.New("no input available (not interactive)")) + var ErrServiceNotFound = errors.New("rotini: service not found") + var ErrShutdownTimeout = InternalError(errors.New("shutdown timed out")) + var ErrUsage = errors.New("usage error") + func AtFrame(i int, hook func(context.Context, *Context)) func(context.Context, *Context) + func Collect[T any](rtx *Context) (T, error) + func DiscoveryDiagnostics(cmd ResolvedCommand) []error + func EnvNoColor() bool + func ExitCode(code int) error + func InternalError(err error) error + func IsTerminal(stream any) bool + func OverlayInputs[T any](layers ...Layer[T]) T + func Ptr[T any](v T) *T + func ReadSecret(r io.Reader) ([]byte, error) + func RemoteBinaryPath(cmd ResolvedCommand, name string) (string, bool) + func Strip(text string) string + func TerminalSize(stream any) (cols, rows int, ok bool) + func UsageError(err error) error + type ArgDef struct + Complete Completion + Default string + Deprecated string + Enum []string + Hidden bool + IgnoreCase bool + Layout string + Name string + Required bool + Secret bool + Separator string + Type string + Variadic bool + type ArgValueCompleter interface + CompleteArgValue func(rtx *Context, arg, partial string) []string + type Base64Bytes []byte + func (b *Base64Bytes) UnmarshalText(text []byte) error + func (b Base64Bytes) MarshalText() ([]byte, error) + func (b Base64Bytes) String() string + type BindError struct + Cause error + Channel string + Input string + Msg string + func (e *BindError) Error() string + func (e *BindError) Unwrap() []error + type BindMeta struct + ConfigFiles []ConfigFile + EnvPrefix string + Sources []recon.Source + StdinSchemas map[string]string + type Binder struct + func NewBinder(meta BindMeta) *Binder + func (b *Binder) Bind(rtx *Context, out any) error + type ByteSize int64 + func (b *ByteSize) UnmarshalText(text []byte) error + func (b ByteSize) MarshalText() ([]byte, error) + func (b ByteSize) String() string + type Category int + const CategoryInternal + const CategoryNone + const CategoryUsage + func CategoryOf(err error) Category + func (c Category) String() string + type CommandDef struct + Aliases []string + Arguments []ArgDef + Commands []CommandDef + Deprecated string + DeprecatedIdentifiers []string + Discovery *RemoteDiscoveryDef + FlagDependencies []FlagDependency + FlagGroups []FlagGroup + Flags []FlagDef + Handler string + Hidden bool + Name string + Passthrough bool + PluginPath string + Remotes []RemoteDef + Summary string + type Completion struct + Extensions []string + Kind string + type ConfigFile struct + Discover *DiscoverDef + Format string + Name string + Path string + PathFrom *PathFromDef + Schema string + Scope string + type Constraints struct + ExclusiveMaximum *float64 + ExclusiveMinimum *float64 + MaxItems int + MaxLength int + Maximum *float64 + MinItems int + MinLength int + Minimum *float64 + MultipleOf *float64 + Pattern string + PatternMessage string + type Context struct + Argv []string + Stderr io.Writer + Stdin io.Reader + Stdout io.Writer + func NewContextFor(def Definition, argv []string) *Context + func (rtx *Context) Bind(key string, value any) *Context + func (rtx *Context) BindIfAbsent(key string, value any) *Context + func (rtx *Context) Chain() []ResolvedCommand + func (rtx *Context) Command() ResolvedCommand + func (rtx *Context) CommandPath() string + func (rtx *Context) Exit(code int) + func (rtx *Context) Failed() bool + func (rtx *Context) Frame() ResolvedCommand + func (rtx *Context) Get[T any](key string) (T, bool) + func (rtx *Context) Halt() + func (rtx *Context) HaltWith(err error) + func (rtx *Context) HaltWithCode(code int) + func (rtx *Context) Help() string + func (rtx *Context) IsLeaf() bool + func (rtx *Context) MustGet[T any](key string) T + func (rtx *Context) Parser() *Parser + func (rtx *Context) RecordError(err error) + func (rtx *Context) RecordInfo(msg string) + func (rtx *Context) RecordSuccess(msg string) + func (rtx *Context) RecordWarning(warn error) + func (rtx *Context) Value(key string) any + func (rtx *Context) Version() string + func (rtx *Context) WithBindMeta(meta BindMeta) *Context + func (rtx *Context) WithBinder(fn func(BindMeta) *Binder) *Context + func (rtx *Context) WithHelp(help HelpFunc) *Context + func (rtx *Context) WithParser(parser *Parser) *Context + func (rtx *Context) WithVersion(version string) *Context + type DefaultCascadingPostRun struct + func (DefaultCascadingPostRun) CascadingPostRun(ctx context.Context, rtx *Context) + type DefaultCascadingPreRun struct + func (DefaultCascadingPreRun) CascadingPreRun(ctx context.Context, rtx *Context) + type DefaultHooks struct + type DefaultPostRun struct + func (DefaultPostRun) PostRun(ctx context.Context, rtx *Context) + type DefaultPreRun struct + func (DefaultPreRun) PreRun(ctx context.Context, rtx *Context) + type Definition struct + Arguments []ArgDef + Commands []CommandDef + Discovery *RemoteDiscoveryDef + FlagDependencies []FlagDependency + FlagGroups []FlagGroup + Flags []FlagDef + Handler string + Name string + Passthrough bool + PluginPath string + RemoteCommands []RemoteDef + type Deprecation struct + Identifier string + Kind string + Message string + Name string + func Deprecations(rtx *Context) []Deprecation + func (d Deprecation) Error() string + type DiscoverDef struct + App string + File string + Strategy string + type DiscoveredPlugin struct + Name string + Path string + func DiscoveredPlugins(cmd ResolvedCommand) []DiscoveredPlugin + type FieldPath string + type FlagDef struct + Complete Completion + Default string + Defaults []string + Deprecated string + DeprecatedIdentifiers []string + DottedKeys bool + Enum []string + From []string + Hidden bool + Identifiers []string + IgnoreCase bool + ImplicitValue string + KeyPaths []string + Layout string + Name string + Negatable bool + ObjectSchema string + Required bool + Secret bool + Separator string + Summary string + Type string + type FlagDependency struct + Requires []string + When string + type FlagGroup struct + Flags []string + Kind FlagGroupKind + type FlagGroupKind string + const FlagGroupAtLeastOne + const FlagGroupMutuallyExclusive + const FlagGroupOneOf + const FlagGroupRequiredTogether + type FlagValueCompleter interface + CompleteFlagValue func(rtx *Context, flag, partial string) []string + type FunnelFunc func(ctx context.Context, rtx *Context, out Outcome) + type Handlers interface + CascadingPostRun func(ctx context.Context, rtx *Context) + CascadingPreRun func(ctx context.Context, rtx *Context) + PostRun func(ctx context.Context, rtx *Context) + PreRun func(ctx context.Context, rtx *Context) + Run func(ctx context.Context, rtx *Context) + type HelpFunc func(path ...string) (string, error) + type HexBytes []byte + func (h *HexBytes) UnmarshalText(text []byte) error + func (h HexBytes) MarshalText() ([]byte, error) + func (h HexBytes) String() string + type Key struct + func NewKey[T any](name string) Key[T] + func (k Key[T]) BindTo(rtx *Context, value T) + func (k Key[T]) Get(rtx *Context) (T, bool) + func (k Key[T]) MustGet(rtx *Context) T + func (k Key[T]) Name() string + func (k Key[T]) Provide(p *Program, value T) *Program + func (k Key[T]) String() string + type Layer struct + Name string + Set Presence + Values T + func Defaults[T any](rtx *Context) (Layer[T], error) + func ParseArgv[T any](rtx *Context) (Layer[T], error) + func ParseEnv[T any](rtx *Context) (Layer[T], error) + func ParseFiles[T any](rtx *Context) (Layer[T], error) + func ParseStdin[T any](rtx *Context) (Layer[T], error) + type Lifecycle func(chain []ResolvedCommand, handlers []Handlers) []LifecycleStep + type LifecycleStep struct + Do func(ctx context.Context, rtx *Context) + Name string + Undo func(ctx context.Context, rtx *Context) + func DefaultLifecycle(chain []ResolvedCommand, handlers []Handlers) []LifecycleStep + type Line struct + Stream Stream + Text string + type Option func(*Program) + func Provide[T any](k Key[T], value T) Option + type Outcome struct + Errors []error + Infos []string + Panics []*PanicError + Successes []string + Warnings []error + func (o Outcome) Empty() bool + func (o Outcome) Failed() bool + type PanicError struct + Stack []byte + Value any + func (e *PanicError) Error() string + func (e *PanicError) Unwrap() []error + type ParseError struct + Candidates []string + Command string + Flag string + Kind ParseKind + Msg string + Token string + func (e *ParseError) Error() string + func (e *ParseError) Unwrap() error + type ParseKind int + const ParseKindConstraintViolation + const ParseKindEnumViolation + const ParseKindInternal + const ParseKindInvalidValue + const ParseKindMissingRequired + const ParseKindNeedsValue + const ParseKindNoArguments + const ParseKindTooManyArguments + const ParseKindUnknownCommand + const ParseKindUnknownFlag + const ParseKindUnspecified + func (k ParseKind) String() string + type Parser struct + func NewParser() *Parser + func (p *Parser) Parse(rtx *Context, out any) error + type PathFromDef struct + Env string + Flag string + type Presence map[FieldPath]Provenance + type Program struct + func NewProgram(def Definition, handlers any) *Program + func (p *Program) Bind(key string, value any) *Program + func (p *Program) Execute() error + func (p *Program) Run(argv []string) (int, error) + func (p *Program) RunContext(ctx context.Context, argv []string) (int, error) + func (p *Program) With(opts ...Option) *Program + func (p *Program) WithArgs(args []string) *Program + func (p *Program) WithBindMeta(meta BindMeta) *Program + func (p *Program) WithBinder(fn func(BindMeta) *Binder) *Program + func (p *Program) WithContext(ctx context.Context) *Program + func (p *Program) WithExit(fn func(int)) *Program + func (p *Program) WithFunnel(fn FunnelFunc) *Program + func (p *Program) WithHelp(help HelpFunc) *Program + func (p *Program) WithLifecycle(fn Lifecycle) *Program + func (p *Program) WithPanicRecover(enabled bool) *Program + func (p *Program) WithParser(parser *Parser) *Program + func (p *Program) WithResolver(fn Resolver) *Program + func (p *Program) WithSignals(sigs ...os.Signal) *Program + func (p *Program) WithStderr(w io.Writer) *Program + func (p *Program) WithStdin(r io.Reader) *Program + func (p *Program) WithStdout(w io.Writer) *Program + func (p *Program) WithTeardownOnPanic(enabled bool) *Program + func (p *Program) WithVersion(version string) *Program + func (p *Program) WithoutSignalHandling() *Program + type Provenance struct + Layer string + Raw string + type REPL struct + func NewREPL(program *Program) *REPL + func (r *REPL) Complete(line string, pos int) []string + func (r *REPL) Run(ctx context.Context) error + func (r *REPL) WithErrorEcho(enabled bool) *REPL + func (r *REPL) WithExitCommands(words ...string) *REPL + func (r *REPL) WithInput(in io.Reader) *REPL + func (r *REPL) WithIntercept(fn func(ctx context.Context, line string) (bool, error)) *REPL + func (r *REPL) WithInterrupts(ch <-chan struct{}) *REPL + func (r *REPL) WithLineReader(fn func(ctx context.Context, prompt string) (string, error)) *REPL + func (r *REPL) WithOutput(out io.Writer) *REPL + func (r *REPL) WithPrompt(prompt string) *REPL + func (r *REPL) WithPromptFunc(fn func() string) *REPL + type RemoteDef struct + Aliases []string + Binary string + Name string + Summary string + Timeout time.Duration + type RemoteDiscoveryDef struct + Hidden bool + Prefix string + type RemoteDispatch struct + Args []string + Def RemoteDef + Dir string + Discovered bool + type RemoteError struct + Binary string + Cause error + Kind RemoteErrorKind + Msg string + Name string + Timeout time.Duration + func (e *RemoteError) Error() string + func (e *RemoteError) Unwrap() []error + type RemoteErrorKind int + const RemoteBinaryNotFound + const RemoteSpawnFailed + const RemoteTimeout + func (k RemoteErrorKind) String() string + type Report struct + func CollectP[T any](rtx *Context) (T, Report, error) + func OverlayInputsP[T any](layers ...Layer[T]) (T, Report) + func (r Report) Fields() []FieldPath + func (r Report) History(path FieldPath) []Provenance + func (r Report) Validate() error + func (r Report) Winner(path FieldPath) (Provenance, bool) + type Resolution struct + Argv []string + Chain []ResolvedCommand + Remote *RemoteDispatch + func DefaultResolver(def Definition, argv []string) (Resolution, error) + type ResolvedCommand struct + Arguments []ArgDef + Commands []CommandDef + Deprecated string + DeprecatedIdentifiers []string + Discovery *RemoteDiscoveryDef + FlagDependencies []FlagDependency + FlagGroups []FlagGroup + Flags []FlagDef + Handler string + Matched string + Name string + Passthrough bool + PluginPath string + Remotes []RemoteDef + type Resolver func(def Definition, argv []string) (Resolution, error) + type Service struct + func NewService() *Service + func (s *Service) Go(name string, fn func(context.Context) error) *Service + func (s *Service) Run(ctx context.Context) error + func (s *Service) WithShutdown(fn func(context.Context) error) *Service + func (s *Service) WithShutdownTimeout(d time.Duration) *Service + type ServiceError struct + Key string + func (e *ServiceError) Error() string + func (e *ServiceError) Unwrap() []error + type Stream int + const StreamStderr + const StreamStdout + func (s Stream) String() string + type Subprocess struct + func NewSubprocess(name string, args ...string) *Subprocess + func (s *Subprocess) Lines(ctx context.Context) iter.Seq2[Line, error] + func (s *Subprocess) Output(ctx context.Context) (string, error) + func (s *Subprocess) Run(ctx context.Context) (int, error) + func (s *Subprocess) WithDir(dir string) *Subprocess + func (s *Subprocess) WithEnv(entries ...string) *Subprocess + func (s *Subprocess) WithStderr(w io.Writer) *Subprocess + func (s *Subprocess) WithStdin(r io.Reader) *Subprocess + func (s *Subprocess) WithStdout(w io.Writer) *Subprocess + func (s *Subprocess) WithTimeout(d time.Duration) *Subprocess + func (s *Subprocess) WithoutParentEnv() *Subprocess + type SubprocessError struct + Args []string + Cause error + ExitCode int + Name string + Stderr string + func (e *SubprocessError) Error() string + func (e *SubprocessError) Unwrap() []error + type Suggestor struct + func NewSuggestor() *Suggestor + func (s *Suggestor) Closest(input string, candidates []string) (suggestion string, ok bool) + func (s *Suggestor) For(err error) []string + func (s *Suggestor) Suggest(input string, candidates []string) []string + func (s *Suggestor) WithMaxResults(n int) *Suggestor + func (s *Suggestor) WithMinScore(score float64) *Suggestor + type WiringError struct + Command string + Handler string + Msg string + func (e *WiringError) Error() string + func (e *WiringError) Unwrap() error