Documentation
¶
Overview ¶
Package command provides the shared identity, exit-code contract, and interleaved flag-parsing primitives used by wind and its subcommands.
Index ¶
- Constants
- Variables
- func FlagDefaults(fs *flag.FlagSet) string
- func IsHelpFlag(token string) bool
- func IsHelpToken(token string) bool
- func NewFlagSet(name string) *flag.FlagSet
- func OptionError(message string) error
- func ParseInterleaved(fs *flag.FlagSet, args []string) ([]string, error)
- func ParseNoPositionals(fs *flag.FlagSet, args []string) error
- func RedactToken(token string) string
- 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 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 ¶
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 ¶
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 all wind diagnostics flow through LineOutput and TerminalCanvas rather than raw stderr.
func OptionError ¶ added in v0.1.7
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 ¶
ParseInterleaved preserves standard flag per-option semantics while allowing positional arguments and options to appear in any order.
func ParseNoPositionals ¶
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
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
ParseExitCode maps a flag-parsing result to the process exit status contract.
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