jpictl: add --version and version command #44
Merged
karasz
merged 1 commits from pr-amery-version
into main
8 months ago
3 changed files with 37 additions and 2 deletions
@ -0,0 +1,31 @@
|
||||
package main |
||||
|
||||
import ( |
||||
_ "embed" |
||||
|
||||
"fmt" |
||||
"os" |
||||
|
||||
"github.com/spf13/cobra" |
||||
) |
||||
|
||||
//go:generate sh -c "git describe | tr -d '\r\n' > .version"
|
||||
//go:embed .version
|
||||
var version string |
||||
|
||||
var versionCmd = &cobra.Command{ |
||||
Use: "version", |
||||
Short: "Returns jpictl's version", |
||||
Args: cobra.NoArgs, |
||||
Run: func(_ *cobra.Command, _ []string) { |
||||
_, _ = fmt.Fprintf(os.Stdout, "%s\n", version) |
||||
}, |
||||
} |
||||
|
||||
func init() { |
||||
if version == "" { |
||||
version = "undetermined" |
||||
} |
||||
|
||||
rootCmd.AddCommand(versionCmd) |
||||
} |
Loading…
Reference in new issue