command

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package command provides the shared identity, exit-code contract, and interleaved flag-parsing primitives used by wind and its subcommands.

Index

Constants

View Source
const Name = "wind"

Name stays independent of os.Args[0] so help and diagnostics remain stable when callers invoke the executable through an absolute path or a symlink.

Variables

View Source
var (
	// ErrHelp reports that argument parsing stopped at a help flag.
	ErrHelp = flag.ErrHelp
	// ErrInternal reports a programming error such as a nil FlagSet.
	ErrInternal = errors.New("command arguments could not be parsed")
)

Functions

func FlagDefaults

func FlagDefaults(fs *flag.FlagSet) string

FlagDefaults renders PrintDefaults for TerminalCanvas. The flag package aligns usage text with tabs, which the canvas would show as literal `\t` escapes, so layout tabs become the spaces a terminal would have displayed.

func IsHelpFlag

func IsHelpFlag(token string) bool

IsHelpFlag reports whether token is a standard flag-style help spelling.

func IsHelpToken

func IsHelpToken(token string) bool

IsHelpToken reports whether token is a help verb or flag spelling.

func NewFlagSet

func NewFlagSet(name string) *flag.FlagSet

NewFlagSet creates a FlagSet with a discard-only output sink because all wind diagnostics flow through LineOutput and TerminalCanvas rather than raw stderr.

func OptionError added in v0.1.7

func OptionError(message string) error

OptionError marks a custom flag validator failure as a complete, self-contained diagnostic so flag parsing surfaces it verbatim without echoing the rejected value or adding another option wrapper.

func ParseInterleaved

func ParseInterleaved(fs *flag.FlagSet, args []string) ([]string, error)

ParseInterleaved preserves standard flag per-option semantics while allowing positional arguments and options to appear in any order.

func ParseNoPositionals

func ParseNoPositionals(fs *flag.FlagSet, args []string) error

ParseNoPositionals parses options with the same diagnostics as ParseInterleaved, but rejects positional arguments immediately so trailing tokens after an invalid positional or "--" cannot be reinterpreted as help.

func RedactToken added in v0.1.7

func RedactToken(token string) string

RedactToken strips any URL fragment from an echoed CLI token so an accidentally pasted share link does not project its #key into error output.

func WriteFlagHelp

func WriteFlagHelp(output LineOutput, fs *flag.FlagSet, synopsis string)

WriteFlagHelp renders only registration-time metadata. PrintDefaults uses DefValue rather than the parsed Value, so help after a positional capability cannot reflect that capability back to the terminal.

func WriteLinef

func WriteLinef(output LineOutput, format string, args ...any)

WriteLinef formats one diagnostic record and writes it to output when non-nil.

func WriteLines

func WriteLines(output LineOutput, records ...string)

WriteLines writes records to output when non-nil.

Types

type ExitCode

type ExitCode int

ExitCode defines the process exit status contract shared across all wind commands so scripts can distinguish retryable network errors, user input errors, and source drift.

const (
	ExitOK      ExitCode = 0
	ExitFailure ExitCode = 1 // Runtime failure: interrupted transfer, local IO, internal error.
	ExitUsage   ExitCode = 2 // User error: arguments, capability/key, selection, manifest limit.
	ExitNetwork ExitCode = 3 // Network or relay unreachable or denied.
	ExitDrift   ExitCode = 4 // Source modified during share.
)

func ParseExitCode added in v0.1.7

func ParseExitCode(err error) ExitCode

ParseExitCode maps a flag-parsing result to the process exit status contract.

func (ExitCode) Int

func (code ExitCode) Int() int

Int returns the OS process exit code.

type LineOutput

type LineOutput interface {
	WriteLines(...string)
}

LineOutput commits complete diagnostic records immediately; it is not a byte stream.

type RepeatedFlag

type RepeatedFlag []string

RepeatedFlag collects repeatable string flags (for example, --only a --only b).

func (*RepeatedFlag) Set

func (f *RepeatedFlag) Set(v string) error

func (*RepeatedFlag) String

func (f *RepeatedFlag) String() string

Jump to

Keyboard shortcuts

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