refactore: refactoring of code

This commit is contained in:
2024-01-19 14:41:25 +01:00
parent 858b508b58
commit 52ed96ae09
6 changed files with 40 additions and 20 deletions

View File

@@ -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
View 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()
}