engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package engine contains the dependency-free argv parsing boundary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Completion

func Completion(root Command, shell string) (string, error)

Completion generates a deterministic completion script.

Types

type Action

type Action uint8

Action identifies parser-owned terminal requests.

const (
	// ActionRun dispatches the selected command.
	ActionRun Action = iota
	// ActionHelp requests framework-generated help.
	ActionHelp
	// ActionVersion requests root version output.
	ActionVersion
)

type Command

type Command struct {
	ID       int
	Name     string
	Aliases  []string
	Summary  string
	Version  string
	Options  []Option
	Children []Command
}

Command is the parser-neutral subset required for token parsing.

type FailureKind

type FailureKind uint8

FailureKind is a stable adapter-level parse classification.

const (
	// FailureUsage identifies a general parsing failure.
	FailureUsage FailureKind = iota
	// FailureUnknownCommand identifies an unknown command token.
	FailureUnknownCommand
	// FailureUnknownOption identifies an unknown option token.
	FailureUnknownOption
	// FailureMissingValue identifies an option missing its value.
	FailureMissingValue
)

type Option

type Option struct {
	Key        int
	Name       string
	Short      rune
	Persistent bool
	Boolean    bool
}

Option declares one parser option.

type ParseError

type ParseError struct {
	Kind FailureKind
}

ParseError insulates public classification from parser implementation details.

func (*ParseError) Error

func (err *ParseError) Error() string

type Result

type Result struct {
	CommandID int
	Action    Action
	Arguments []string
	Options   map[int][]string
}

Result contains raw values for owned typed conversion.

func Parse

func Parse(ctx context.Context, root Command, argv []string) (Result, error)

Parse evaluates one immutable command tree without global parser state.

type UnsupportedShellError

type UnsupportedShellError struct{ Shell string }

UnsupportedShellError identifies an unsupported generator name.

func (*UnsupportedShellError) Error

func (err *UnsupportedShellError) Error() string

Jump to

Keyboard shortcuts

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