mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 08:14:46 +00:00
Display version and license on each run
Signed-off-by: Ettore Di Giacinto <mudler@sabayon.org>
This commit is contained in:
18
cmd/root.go
18
cmd/root.go
@@ -43,6 +43,12 @@ var LockedCommands = []string{"install", "uninstall", "upgrade"}
|
|||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.16.7"
|
LuetCLIVersion = "0.16.7"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
|
license = `
|
||||||
|
Luet Copyright (C) 2019-2021 Ettore Di Giacinto
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions.
|
||||||
|
`
|
||||||
)
|
)
|
||||||
|
|
||||||
// Build time and commit information.
|
// Build time and commit information.
|
||||||
@@ -53,6 +59,10 @@ var (
|
|||||||
BuildCommit string
|
BuildCommit string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func version() string {
|
||||||
|
return fmt.Sprintf("%s-g%s %s", LuetCLIVersion, BuildCommit, BuildTime)
|
||||||
|
}
|
||||||
|
|
||||||
// RootCmd represents the base command when called without any subcommands
|
// RootCmd represents the base command when called without any subcommands
|
||||||
var RootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "luet",
|
Use: "luet",
|
||||||
@@ -80,8 +90,14 @@ To build a package, from a tree definition:
|
|||||||
$ luet build --tree tree/path package
|
$ luet build --tree tree/path package
|
||||||
|
|
||||||
`,
|
`,
|
||||||
Version: fmt.Sprintf("%s-g%s %s", LuetCLIVersion, BuildCommit, BuildTime),
|
Version: version(),
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
if len(os.Args) > 1 {
|
||||||
|
if os.Args[1] != "search" {
|
||||||
|
Info("Luet version", version())
|
||||||
|
Info(license)
|
||||||
|
}
|
||||||
|
}
|
||||||
err := LoadConfig(config.LuetCfg)
|
err := LoadConfig(config.LuetCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatal("failed to load configuration:", err.Error())
|
Fatal("failed to load configuration:", err.Error())
|
||||||
|
Reference in New Issue
Block a user