Documentation
¶
Overview ¶
Package surface captures and compares the stable public Cobra API.
Index ¶
- Constants
- func Encode(snapshot Snapshot) ([]byte, error)
- func PreserveArgumentContract(command *cobra.Command)
- func ValidateTransition(fromVersion, toVersion int, before, after Snapshot, approvals []BreakApproval) error
- type BreakApproval
- type BreakPolicy
- type Change
- type Command
- type Flag
- type Snapshot
Constants ¶
View Source
const SchemaVersion = 1
Variables ¶
This section is empty.
Functions ¶
func PreserveArgumentContract ¶
PreserveArgumentContract records the current positional contract before a wrapper adds cross-cutting behavior such as structured error classification. The wrapper must not change which argument counts are accepted.
func ValidateTransition ¶
func ValidateTransition(fromVersion, toVersion int, before, after Snapshot, approvals []BreakApproval) error
Types ¶
type BreakApproval ¶
type BreakPolicy ¶
type BreakPolicy struct {
SchemaVersion int `json:"schema_version"`
Changes []BreakApproval `json:"changes"`
}
func ParseBreakPolicy ¶
func ParseBreakPolicy(data []byte) (BreakPolicy, error)
type Change ¶
type Command ¶
type Command struct {
Path string `json:"path"`
Name string `json:"name"`
Kind string `json:"kind"`
Use string `json:"use"`
ArgumentPattern string `json:"argument_pattern,omitempty"`
ArgumentContract string `json:"argument_contract"`
Aliases []string `json:"aliases,omitempty"`
ArgumentAliases []string `json:"argument_aliases,omitempty"`
ValidArguments []string `json:"valid_arguments,omitempty"`
GroupID string `json:"group_id,omitempty"`
Runnable bool `json:"runnable"`
Deprecated string `json:"deprecated,omitempty"`
DisableFlagParsing bool `json:"disable_flag_parsing,omitempty"`
TraverseChildren bool `json:"traverse_children,omitempty"`
UnknownFlagsAllowed bool `json:"unknown_flags_allowed,omitempty"`
Flags []Flag `json:"flags,omitempty"`
}
type Flag ¶
type Flag struct {
Name string `json:"name"`
Scope string `json:"scope"`
Shorthand string `json:"shorthand,omitempty"`
Type string `json:"type"`
Default string `json:"default"`
NoOptValue string `json:"no_option_value,omitempty"`
Required bool `json:"required"`
Deprecated string `json:"deprecated,omitempty"`
Hidden bool `json:"hidden"`
}
type Snapshot ¶
type Snapshot struct {
SchemaVersion int `json:"schema_version"`
Commands []Command `json:"commands"`
}
Snapshot is a deterministic description of every visible command and flag.
Click to show internal directories.
Click to hide internal directories.