NewVersionCommand creates the version command. The version value is supplied by main so release builds can continue setting it with ldflags.
(version string)
| 40 | // NewVersionCommand creates the version command. The version value is supplied |
| 41 | // by main so release builds can continue setting it with ldflags. |
| 42 | func NewVersionCommand(version string) *cobra.Command { |
| 43 | versionCmd := &cobra.Command{ |
| 44 | Use: "version", |
| 45 | Short: "Print version information", |
| 46 | RunE: func(cmd *cobra.Command, args []string) error { |
| 47 | return versionCommand(cmd, version) |
| 48 | }, |
| 49 | } |
| 50 | enableStructuredOutput(versionCmd) |
| 51 | return versionCmd |
| 52 | } |
| 53 | |
| 54 | func versionCommand(cmd *cobra.Command, version string) error { |
| 55 | info := newVersionOutput(version) |