misccmd.go 611 Bytes
Newer Older
luxq's avatar
luxq committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
package main

import (
	"fmt"
	"github.com/odysseus/nodemanager/versions"

	"github.com/spf13/cobra"
)

var versionDetail bool

func init() {
	RootCmd.AddCommand(versionCmd)

	versionDetail = *versionCmd.Flags().BoolP("detail", "d", true, "Print detail version info")
}

// versionCmd represents the base command when called without any subcommands
var versionCmd = &cobra.Command{
	Use:   "version",
	Short: "Print version number",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		if versionDetail {
			fmt.Println(versions.DetailVersion())
		} else {
			fmt.Println(versions.Version())
		}
	},
}