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
- func FlagDefaults(fs *flag.FlagSet) string
- func IsHelpFlag(token string) bool
- func IsHelpToken(token string) bool
- func NewFlagSet(name string) *flag.FlagSet
- func WriteFlagHelp(output LineOutput, fs *flag.FlagSet, synopsis string)
- func WriteLinef(output LineOutput, format string, args ...any)
- func WriteLines(output LineOutput, records ...string)
- type ExitCode
- type LineOutput
- type ParseOutcome
- type RepeatedFlag
Constants ¶
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 ¶
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 ¶
IsHelpFlag reports whether token is a standard flag-style help spelling.
func IsHelpToken ¶
IsHelpToken reports whether token is a help verb or flag spelling.
func NewFlagSet ¶
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. )
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