Skip to content

Commit

Permalink
Version command
Browse files Browse the repository at this point in the history
  • Loading branch information
sgonzalezoyuela committed Nov 29, 2022
1 parent 3fe6374 commit c0e5f84
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/spf13/viper"
)

const VERSION = "0.4.0"

var (
cfgFile string
verbose bool
Expand Down
33 changes: 33 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "prints command version",
Long: `the version of the ctl command.`,
Run: func(cmd *cobra.Command, args []string) {
versionCobra(cmd, args)
},
}

func init() {
rootCmd.AddCommand(versionCmd)
}

func versionCobra(cmd *cobra.Command, args []string) {
version()
}

func version() {
fmt.Printf("v%s \n", VERSION)
}

0 comments on commit c0e5f84

Please sign in to comment.