Documentation
¶
Overview ¶
Package cobracmd provides shared Cobra command utilities used across multiple internal packages (app, cli, compat, helpers).
Index ¶
- func ChildByName(parent *cobra.Command, name string) *cobra.Command
- func FlagChanged(cmd *cobra.Command, name string) bool
- func IsGenericOverlayShort(s string) bool
- func LegacyCommandPath(cmd *cobra.Command) string
- func LocalFlagCount(cmd *cobra.Command) int
- func MergeCommandTree(dst, src *cobra.Command)
- func NewGroupCommand(use, short string) *cobra.Command
- func NewHiddenGroupCommand(use, short string) *cobra.Command
- func NewPlaceholderParent(use, short string, children ...*cobra.Command) *cobra.Command
- func OverridePriority(cmd *cobra.Command) int
- func ReplaceChild(parent, oldChild, newChild *cobra.Command)
- func SetOverridePriority(cmd *cobra.Command, priority int)
- func ShouldReplaceLeaf(dst, src *cobra.Command) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChildByName ¶
ChildByName returns the child command with the given name, or nil.
func FlagChanged ¶
FlagChanged reports whether the named flag was explicitly set by the user.
func IsGenericOverlayShort ¶
IsGenericOverlayShort returns true if the description is an auto-generated overlay placeholder that should be overwritten by richer metadata.
func LegacyCommandPath ¶
LegacyCommandPath returns the command path with the root "dws " prefix stripped.
func LocalFlagCount ¶
LocalFlagCount returns the number of visible local flags on cmd.
func MergeCommandTree ¶
MergeCommandTree recursively merges src's children into dst. If a child exists in both trees, the one with higher override priority (or more local flags) wins for leaf commands; groups are merged recursively.
func NewGroupCommand ¶
NewGroupCommand creates a non-leaf parent command that shows help when invoked.
func NewHiddenGroupCommand ¶
NewHiddenGroupCommand creates a hidden non-leaf parent command.
func NewPlaceholderParent ¶
NewPlaceholderParent creates a non-leaf parent command with pre-attached children.
func OverridePriority ¶
OverridePriority returns the override priority annotation value, or 0.
func ReplaceChild ¶
ReplaceChild removes oldChild from parent and adds newChild.
func SetOverridePriority ¶
SetOverridePriority sets the override priority annotation on cmd.
func ShouldReplaceLeaf ¶
ShouldReplaceLeaf decides whether src should replace dst as a leaf command based on override priority and local flag count.
Types ¶
This section is empty.