MCPcopy
hub / github.com/cli/cli / NoArgsQuoteReminder

Function NoArgsQuoteReminder

pkg/cmdutil/args.go:38–60  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

36}
37
38func NoArgsQuoteReminder(cmd *cobra.Command, args []string) error {
39 if len(args) < 1 {
40 return nil
41 }
42
43 errMsg := fmt.Sprintf("unknown argument %q", args[0])
44 if len(args) > 1 {
45 errMsg = fmt.Sprintf("unknown arguments %q", args)
46 }
47
48 hasValueFlag := false
49 cmd.Flags().Visit(func(f *pflag.Flag) {
50 if f.Value.Type() != "bool" {
51 hasValueFlag = true
52 }
53 })
54
55 if hasValueFlag {
56 errMsg += "; please quote all values that have spaces"
57 }
58
59 return FlagErrorf("%s", errMsg)
60}
61
62// Partition takes a slice of any type T and separates it into two slices
63// of the same type based on the provided predicate function. Any item

Callers

nothing calls this directly

Calls 2

FlagErrorfFunction · 0.85
TypeMethod · 0.45

Tested by

no test coverage detected