MCPcopy Create free account
hub / github.com/alibaba/open-code-review / positionalSignature

Function positionalSignature

cmd/opencodereview/arg_errors.go:92–105  ·  view source on GitHub ↗

positionalSignature extracts the positional-argument part of cmd.Use, e.g. " " from "set " and " " from "rule [flags] ". Bracketed fields are not placeholders the user types, so "[flags]" and inline enumerations such as "[bash|zsh]" are dropped; enumerated v

(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

90// types, so "[flags]" and inline enumerations such as "[bash|zsh]" are dropped;
91// enumerated values are reported from ValidArgs instead.
92func positionalSignature(cmd *cobra.Command) string {
93 fields := strings.Fields(cmd.Use)
94 if len(fields) < 2 {
95 return ""
96 }
97
98 parts := make([]string, 0, len(fields)-1)
99 for _, f := range fields[1:] {
100 if strings.HasPrefix(f, "<") {
101 parts = append(parts, f)
102 }
103 }
104 return strings.Join(parts, " ")
105}
106
107// validArgNames strips the "name\tdescription" form Cobra allows in ValidArgs,
108// keeping only the value the user is expected to type. The split matches the one

Callers 3

TestPositionalSignatureFunction · 0.85
argCountErrorFunction · 0.85

Calls

no outgoing calls