cli

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeOptions

func NormalizeOptions(args []string, shortOptions, longOptions map[string]struct{}) ([]string, error)

NormalizeOptions validates POSIX/GNU option spelling and converts long options to the form expected by Go's flag package. Short options use one dash (-v) and long options use two dashes (--run).

func SilentExit

func SilentExit(code int) error

Types

type Command

type Command interface {
	Name() string
	Description() string
	Help() string
	Run(ctx Context, args []string) error
}

type Context

type Context struct {
	WorkDir string
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
}

type ContextualHelp

type ContextualHelp interface {
	HelpFor(args []string) (string, error)
}

ContextualHelp is implemented by commands with subcommands. The arguments identify the requested subcommand path, for example ["add"] for "gox help client add".

type Router

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

func NewRouter

func NewRouter(commands ...Command) *Router

func (*Router) Run

func (r *Router) Run(ctx Context, args []string) error

type SilentExitError

type SilentExitError struct {
	Code int
}

SilentExitError tells main to exit with Code without logging the error message.

func (SilentExitError) Error

func (e SilentExitError) Error() string

Jump to

Keyboard shortcuts

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