MCPcopy
hub / github.com/larksuite/cli / unknownFlagTokens

Function unknownFlagTokens

cmd/root.go:455–464  ·  view source on GitHub ↗

unknownFlagTokens returns the flag tokens in rawArgs that cmd does not define (on itself, inherited, or any direct subcommand). installUnknownSubcommandGuard whitelists unknown flags on pure groups so a mistyped subcommand still reaches the suggestion path; the side effect is that flags before a sub

(cmd *cobra.Command, rawArgs []string)

Source from the content-addressed store, hash-verified

453// swallowed. This recovers the genuinely-unknown ones so the caller can name
454// them in a "did you mean" envelope.
455func unknownFlagTokens(cmd *cobra.Command, rawArgs []string) []string {
456 var unknown []string
457 for _, a := range flagTokensInArgs(rawArgs) {
458 name := strings.SplitN(strings.TrimLeft(a, "-"), "=", 2)[0]
459 if name != "" && !flagDefinedInTree(cmd, name) {
460 unknown = append(unknown, a)
461 }
462 }
463 return unknown
464}
465
466// flagKnownOnGroup reports whether name is a flag defined on cmd itself or
467// inherited (a global persistent flag like --profile) — i.e. valid on the bare

Callers 2

unknownSubcommandRunEFunction · 0.85
TestUnknownFlagTokensFunction · 0.85

Calls 2

flagTokensInArgsFunction · 0.85
flagDefinedInTreeFunction · 0.85

Tested by 1

TestUnknownFlagTokensFunction · 0.68