mod(cli): remove version command and replace with flag instead
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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")
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user