mod(cli): remove version command and replace with flag instead

This commit is contained in:
2023-10-26 15:57:20 +02:00
parent f57c65fba2
commit 65df4be21c
2 changed files with 6 additions and 20 deletions

View File

@@ -8,7 +8,10 @@ import (
"github.com/spf13/viper"
)
const VERSION string = "0.1"
var (
version bool
dry_run bool
rootCmd = &cobra.Command{
Use: "gitw",
@@ -24,6 +27,9 @@ func Execute() error {
func init() {
cobra.OnInitialize(initConfig)
// version flag
rootCmd.Flags().BoolVarP(&version, "version", "v", false, "Print version of gitwarrior")
rootCmd.Version = VERSION
}
func initConfig() {

View File

@@ -1,20 +0,0 @@
package cmd
import (
"fmt"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(versionCmd)
}
var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version of gitwarrior",
Long: `All software has versions. This is gitwarrior's`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("v0.1")
},
}