(cmd *cobra.Command)
| 11 | ) |
| 12 | |
| 13 | func jsonFieldsFor(cmd *cobra.Command) []string { |
| 14 | // This annotation is added by the `cmdutil.AddJSONFlags` function. |
| 15 | // |
| 16 | // This is an extremely janky way to get access to this information but due to the fact we pass |
| 17 | // around concrete cobra.Command structs, there's no viable way to have typed access to the fields. |
| 18 | // |
| 19 | // It's also kind of fragile because it's several hops away from the code that actually validates the usage |
| 20 | // of these flags, so it's possible for things to get out of sync. |
| 21 | stringFields, ok := cmd.Annotations["help:json-fields"] |
| 22 | if !ok { |
| 23 | return nil |
| 24 | } |
| 25 | |
| 26 | return strings.Split(stringFields, ",") |
| 27 | } |
| 28 | |
| 29 | // NewCmdFunc represents the typical function signature we use for creating commands e.g. `NewCmdView`. |
| 30 | // |
no outgoing calls
no test coverage detected