[#159] Add version-command for ots-cli

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-12-13 16:26:33 +01:00
parent 47a7a686ef
commit f2a7af30b2
No known key found for this signature in database
GPG Key ID: D91C3E91E4CAD6F5
2 changed files with 21 additions and 0 deletions

View 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)
}

View File

@ -4,6 +4,8 @@ import (
"os"
)
var version = "dev"
func main() {
if err := rootCmd.Execute(); err != nil {
os.Exit(1)