mirror of
https://github.com/mudler/luet.git
synced 2025-09-19 09:43:27 +00:00
Don't hardcode the version (#353)
and add a `version` command that only prints the version (without the build time) Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
committed by
GitHub
parent
4c788ccbd1
commit
f3480f8f8d
@@ -30,8 +30,7 @@ var cfgFile string
|
||||
var Verbose bool
|
||||
|
||||
const (
|
||||
LuetCLIVersion = "0.34.0"
|
||||
LuetEnvPrefix = "LUET"
|
||||
LuetEnvPrefix = "LUET"
|
||||
)
|
||||
|
||||
var license = []string{
|
||||
@@ -45,12 +44,12 @@ var license = []string{
|
||||
//
|
||||
// ⚠️ WARNING: should only be set by "-ldflags".
|
||||
var (
|
||||
BuildTime string
|
||||
BuildCommit string
|
||||
BuildTime string
|
||||
Version = "0.0.0"
|
||||
)
|
||||
|
||||
func version() string {
|
||||
return fmt.Sprintf("%s-g%s %s", LuetCLIVersion, BuildCommit, BuildTime)
|
||||
return fmt.Sprintf("%s (Build time: %s)", Version, BuildTime)
|
||||
}
|
||||
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
|
19
cmd/version.go
Normal file
19
cmd/version.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
RootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version of luet",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println(Version)
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user