Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Distance ¶
Distance is the Levenshtein edit distance between a and b. It backs the "did you mean --x?" suggestions for unknown flags and unknown :help <command> names. Kept here so both the api (validation) and command (help) packages can use it without an import cycle.
Types ¶
type Aliaser ¶
type Aliaser interface {
AliasOf() string
}
Aliaser is optionally implemented by alias commands to indicate which primary command they delegate to.
type Command ¶
type CommandSpec ¶
type CommandSpec struct {
// Usage is the positional usage, e.g. "[command]" or "" for none.
Usage string
// Detail is optional prose rendered under USAGE — explain modes,
// e.g. that running with no flags starts an interactive flow.
Detail string
// Flags is the accepted-flag allow-list for strict validation.
Flags []FlagSpec
// Examples are full example invocations, incl. the leading ':'.
Examples []string
// Passthrough disables both help interception and strict flag
// validation for this command: every argument reaches Execute
// unchanged. Intended only for delegating/unavailable stubs (e.g.
// the OSS bootstrap stub) that must keep their own messaging and
// must not document Pro internals in the OSS repo.
Passthrough bool
}
CommandSpec is the optional, declarative documentation/validation contract for a command. Commands expose it via CommandWithSpec.
func SpecOf ¶
func SpecOf(cmd Command) (CommandSpec, bool)
SpecOf resolves a command's spec, following Aliaser → primary so an alias transparently inherits its target's documentation and validation rules.
type CommandWithAliases ¶
CommandWithAliases pairs a primary command with its collected alias names.
func PrimaryCommands ¶
func PrimaryCommands() []CommandWithAliases
PrimaryCommands returns deduplicated commands with alias names collected. Commands implementing Aliaser are folded into their target's Aliases slice.
type CommandWithSpec ¶
type CommandWithSpec interface {
Spec() CommandSpec
}
CommandWithSpec is the optional capability interface. It mirrors the Aliaser pattern: discovered via type assertion, additive and non-breaking across the swarmcli ↔ swarmcli-be module boundary.
type FlagSpec ¶
type FlagSpec struct {
Name string // long flag, without leading "--" (e.g. "node-id")
Short string // optional single-char alias without "-"; "" = none
TakesValue bool // false ⇒ boolean (--force); true ⇒ --host <value>
Placeholder string // usage value placeholder, e.g. "<host>"; used only if TakesValue
Description string
}
FlagSpec declares a single flag a command accepts. It drives both the per-command help screen and strict unknown-flag validation.