cobracmd

package
v1.0.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cobracmd provides shared Cobra command utilities used across multiple internal packages (app, cli, compat, helpers).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChildByName

func ChildByName(parent *cobra.Command, name string) *cobra.Command

ChildByName returns the child command with the given name, or nil.

func FlagChanged

func FlagChanged(cmd *cobra.Command, name string) bool

FlagChanged reports whether the named flag was explicitly set by the user.

func IsGenericOverlayShort

func IsGenericOverlayShort(s string) bool

IsGenericOverlayShort returns true if the description is an auto-generated overlay placeholder that should be overwritten by richer metadata.

func LegacyCommandPath

func LegacyCommandPath(cmd *cobra.Command) string

LegacyCommandPath returns the command path with the root "dws " prefix stripped.

func LocalFlagCount

func LocalFlagCount(cmd *cobra.Command) int

LocalFlagCount returns the number of visible local flags on cmd.

func MergeCommandTree

func MergeCommandTree(dst, src *cobra.Command)

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

func NewGroupCommand(use, short string) *cobra.Command

NewGroupCommand creates a non-leaf parent command that shows help when invoked.

func NewHiddenGroupCommand

func NewHiddenGroupCommand(use, short string) *cobra.Command

NewHiddenGroupCommand creates a hidden non-leaf parent command.

func NewPlaceholderParent

func NewPlaceholderParent(use, short string, children ...*cobra.Command) *cobra.Command

NewPlaceholderParent creates a non-leaf parent command with pre-attached children.

func OverridePriority

func OverridePriority(cmd *cobra.Command) int

OverridePriority delegates to cmdutil.OverridePriority.

func ReplaceChild

func ReplaceChild(parent, oldChild, newChild *cobra.Command)

ReplaceChild removes oldChild from parent and adds newChild.

func SetOverridePriority

func SetOverridePriority(cmd *cobra.Command, priority int)

SetOverridePriority delegates to cmdutil.SetOverridePriority so internal and external call sites share one annotation key.

func ShouldReplaceLeaf

func ShouldReplaceLeaf(dst, src *cobra.Command) bool

ShouldReplaceLeaf decides whether src should replace dst as a leaf command based on override priority and local flag count.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL