(plugin *cobra.Command, meta metadata.Metadata)
| 203 | } |
| 204 | |
| 205 | func newMetadataSubcommand(plugin *cobra.Command, meta metadata.Metadata) *cobra.Command { |
| 206 | if meta.ShortDescription == "" { |
| 207 | meta.ShortDescription = plugin.Short |
| 208 | } |
| 209 | cmd := &cobra.Command{ |
| 210 | Use: metadata.MetadataSubcommandName, |
| 211 | Hidden: true, |
| 212 | // Suppress the global/parent PersistentPreRunE, which |
| 213 | // needlessly initializes the client and tries to |
| 214 | // connect to the daemon. |
| 215 | PersistentPreRun: func(cmd *cobra.Command, args []string) {}, |
| 216 | RunE: func(cmd *cobra.Command, args []string) error { |
| 217 | enc := json.NewEncoder(os.Stdout) |
| 218 | enc.SetEscapeHTML(false) |
| 219 | enc.SetIndent("", " ") |
| 220 | return enc.Encode(meta) |
| 221 | }, |
| 222 | } |
| 223 | return cmd |
| 224 | } |
| 225 | |
| 226 | // RunningStandalone tells a CLI plugin it is run standalone by direct execution |
| 227 | func RunningStandalone() bool { |
no outgoing calls
no test coverage detected
searching dependent graphs…