MCPcopy Create free account
hub / github.com/algolia/cli / AddFlags

Method AddFlags

pkg/cmdutil/print_flags.go:103–117  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

101}
102
103func (f *PrintFlags) AddFlags(cmd *cobra.Command) {
104 f.JSONPrintFlags.AddFlags(cmd)
105 f.JSONPathPrintFlags.AddFlags(cmd)
106
107 if f.OutputFormat != nil {
108 cmd.Flags().
109 StringVarP(f.OutputFormat, "output", "o", *f.OutputFormat, fmt.Sprintf(`Output format. One of: (%s).`, strings.Join(f.AllowedFormats(), ", ")))
110 _ = cmd.Flags().SetAnnotation("output", "IsPrint", []string{"true"})
111 if f.OutputFlagSpecified == nil {
112 f.OutputFlagSpecified = func() bool {
113 return cmd.Flag("output").Changed
114 }
115 }
116 }
117}
118
119// WithDefaultOutput sets a default output format if one is not provided through a flag value
120func (f *PrintFlags) WithDefaultOutput(output string) *PrintFlags {

Callers

nothing calls this directly

Calls 1

AllowedFormatsMethod · 0.95

Tested by

no test coverage detected