(cmd *cobra.Command)
| 101 | } |
| 102 | |
| 103 | func (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 |
| 120 | func (f *PrintFlags) WithDefaultOutput(output string) *PrintFlags { |
nothing calls this directly
no test coverage detected