(cmd *cobra.Command)
| 119 | } |
| 120 | |
| 121 | func checkJSONFlags(cmd *cobra.Command) (*jsonExporter, error) { |
| 122 | f := cmd.Flags() |
| 123 | jsonFlag := f.Lookup("json") |
| 124 | jqFlag := f.Lookup("jq") |
| 125 | tplFlag := f.Lookup("template") |
| 126 | webFlag := f.Lookup("web") |
| 127 | |
| 128 | if jsonFlag.Changed { |
| 129 | if webFlag != nil && webFlag.Changed { |
| 130 | return nil, errors.New("cannot use `--web` with `--json`") |
| 131 | } |
| 132 | jv := jsonFlag.Value.(pflag.SliceValue) |
| 133 | return &jsonExporter{ |
| 134 | fields: jv.GetSlice(), |
| 135 | filter: jqFlag.Value.String(), |
| 136 | template: tplFlag.Value.String(), |
| 137 | }, nil |
| 138 | } else if jqFlag.Changed { |
| 139 | return nil, errors.New("cannot use `--jq` without specifying `--json`") |
| 140 | } else if tplFlag.Changed { |
| 141 | return nil, errors.New("cannot use `--template` without specifying `--json`") |
| 142 | } |
| 143 | return nil, nil |
| 144 | } |
| 145 | |
| 146 | func AddFormatFlags(cmd *cobra.Command, exportTarget *Exporter) { |
| 147 | var format string |
no test coverage detected