command

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 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 privacy-safe 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

This section is empty.

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 the standard library quotes rejected option values in its error messages. Human diagnostics are produced from ParseOutcome instead.

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 (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 ParseOutcome

type ParseOutcome uint8

ParseOutcome classifies flag parsing outcomes into a closed set so rejected command-line values (such as accidentally pasted capability links or keys) are never reflected back to terminal output.

const (
	ParseReady ParseOutcome = iota
	ParseHelp
	ParseUnknownOption
	ParseMissingOptionValue
	ParseInvalidOptionValue
	ParseInvalidOptionSyntax
	ParseUnexpectedPositional
	ParseInternalFailure
)

func ParseInterleaved

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

ParseInterleaved preserves the standard flag package's per-option semantics while allowing positional arguments and options to appear in any order. Parsing one occurrence at a time lets the boundary classify failures from option structure without inspecting value-bearing error text.

func ParseNoPositionals

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

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

func (ParseOutcome) Diagnostic

func (outcome ParseOutcome) Diagnostic() string

Diagnostic returns a closed, value-free human diagnostic for a non-ready parse outcome.

func (ParseOutcome) ExitCode

func (outcome ParseOutcome) ExitCode() ExitCode

ExitCode maps a parse outcome to the process exit status contract.

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