app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = []CommandDef{}

Registry holds the root commands of the application

Functions

func ValidateFlags

func ValidateFlags(flags map[string]any, defs []FlagDef) error

ValidateFlags checks flag dependencies and conflicts

Types

type CommandDef

type CommandDef struct {
	Use         string
	Short       string
	Long        string
	Flags       []FlagDef
	Handler     HandlerFunc
	SubCommands []CommandDef
}

CommandDef defines a single command in the application

type FlagDef

type FlagDef struct {
	Name          string
	Shorthand     string
	Usage         string
	Type          InputType
	DefaultVal    any
	Required      bool
	Options       []string // For InputChoice - valid choices
	RequiresFlags []string // Flags that must be set with this one
	ConflictsWith []string // Flags that cannot be used with this one
}

FlagDef defines a command argument/flag

type HandlerFunc

type HandlerFunc func(ctx context.Context, w io.Writer, flags map[string]any) (any, error)

HandlerFunc is the logic that runs for a command. It receives context, a writer for text output, and flag values. It returns a structured result and an error.

type InputType

type InputType int

InputType represents the type of UI input required

const (
	InputNone InputType = iota
	InputString
	InputLongString
	InputList
	InputInt
	InputBool
	InputPassword
	InputFile
	InputDate
	InputChoice
)

Different accepted input types for cmd and tui

Jump to

Keyboard shortcuts

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