refactore: refactoring of code
This commit is contained in:
@@ -50,5 +50,6 @@ func init() {
|
||||
rootCmd.PersistentFlags().IntP("port", "p", 5432, "Set database port")
|
||||
rootCmd.PersistentFlags().BoolP("help", "h", false, "Print this help message")
|
||||
rootCmd.PersistentFlags().BoolP("version", "v", false, "shows version information")
|
||||
rootCmd.AddCommand(VersionCmd)
|
||||
|
||||
}
|
||||
|
||||
23
cmd/version.go
Normal file
23
cmd/version.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var appVersion = os.Getenv("VERSION")
|
||||
|
||||
var VersionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show version",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
Version()
|
||||
},
|
||||
}
|
||||
|
||||
// Version display application version
|
||||
func Version() {
|
||||
fmt.Printf("Version: %s \n", appVersion)
|
||||
fmt.Print()
|
||||
}
|
||||
Reference in New Issue
Block a user