[#159] Add version-command for ots-cli
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
47a7a686ef
commit
f2a7af30b2
2 changed files with 21 additions and 0 deletions
19
cmd/ots-cli/cmd_version.go
Normal file
19
cmd/ots-cli/cmd_version.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Displays the tool version",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("ots-cli %s\n", version) //nolint:forbidigo
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
|
@ -4,6 +4,8 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
var version = "dev"
|
||||
|
||||
func main() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Reference in a new issue