diff --git a/cmd/root.go b/cmd/root.go index 1a421f0e..7a3f67f7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -35,9 +35,10 @@ const ( ) var license = []string{ - "Luet Copyright (C) 2019-2022 Ettore Di Giacinto", + "Copyright (C) 2019-2022 Ettore Di Giacinto", "This program comes with ABSOLUTELY NO WARRANTY.", "This is free software, and you are welcome to redistribute it under certain conditions.", + "For documentation, visit https://luet.io.", } // Build time and commit information. @@ -56,7 +57,9 @@ func version() string { var RootCmd = &cobra.Command{ Use: "luet", Short: "Container based package manager", - Long: `Luet is a single-binary package manager based on containers to build packages. + Long: `Luet is a single-binary package manager based on containers to build packages. + +For documentation, visit https://luet.io. To install a package: @@ -89,7 +92,7 @@ To build a package, from a tree definition: util.DefaultContext = ctx - util.DisplayVersionBanner(util.DefaultContext, util.IntroScreen, version, license) + util.DisplayVersionBanner(util.DefaultContext, version, license) viper.BindPFlag("plugin", cmd.Flags().Lookup("plugin")) @@ -116,7 +119,7 @@ To build a package, from a tree definition: // Execute adds all child commands to the root command sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - util.HandleLock(util.DefaultContext) + util.HandleLock() if err := RootCmd.Execute(); err != nil { fmt.Println(err) diff --git a/cmd/util/cli.go b/cmd/util/cli.go index 5ee02422..7c76d424 100644 --- a/cmd/util/cli.go +++ b/cmd/util/cli.go @@ -16,6 +16,7 @@ package util import ( + "fmt" "os" "strings" @@ -26,7 +27,6 @@ import ( "github.com/mudler/luet/pkg/api/core/context" "github.com/mudler/luet/pkg/api/core/template" - "github.com/mudler/luet/pkg/api/core/types" "github.com/mudler/luet/pkg/installer" ) @@ -54,38 +54,33 @@ func TemplateFolders(ctx *context.Context, i installer.BuildTreeResult, treePath return templateFolders } -func IntroScreen() { - luetLogo, _ := pterm.DefaultBigText.WithLetters( - pterm.NewLettersFromStringWithStyle("LU", pterm.NewStyle(pterm.FgLightMagenta)), - pterm.NewLettersFromStringWithStyle("ET", pterm.NewStyle(pterm.FgLightBlue))). - Srender() +func HandleLock() { + if os.Getenv("LUET_NOLOCK") == "true" { + return + } - pterm.DefaultCenter.Print(luetLogo) + if len(os.Args) == 0 { + return + } - pterm.DefaultCenter.Print(pterm.DefaultHeader.WithFullWidth().WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Sprint("Luet - 0-deps container-based package manager")) -} - -func HandleLock(c types.Context) { - if os.Getenv("LUET_NOLOCK") != "true" { - if len(os.Args) > 1 { - for _, lockedCmd := range lockedCommands { - if os.Args[1] == lockedCmd { - s := single.New("luet") - if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning { - c.Fatal("another instance of the app is already running, exiting") - } else if err != nil { - // Another error occurred, might be worth handling it as well - c.Fatal("failed to acquire exclusive app lock:", err.Error()) - } - defer s.TryUnlock() - break - } + for _, lockedCmd := range lockedCommands { + if os.Args[1] == lockedCmd { + s := single.New("luet") + if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning { + fmt.Println("another instance of the app is already running, exiting") + os.Exit(1) + } else if err != nil { + // Another error occurred, might be worth handling it as well + fmt.Println("failed to acquire exclusive app lock:", err.Error()) + os.Exit(1) } + defer s.TryUnlock() + break } } } -func DisplayVersionBanner(c *context.Context, banner func(), version func() string, license []string) { +func DisplayVersionBanner(c *context.Context, version func() string, license []string) { display := false if len(os.Args) > 1 { for _, c := range bannerCommands { @@ -95,15 +90,7 @@ func DisplayVersionBanner(c *context.Context, banner func(), version func() stri } } if display { - if c.Config.General.Quiet { - pterm.Info.Printf("Luet %s\n", version()) - pterm.Info.Println(strings.Join(license, "\n")) - } else { - banner() - pterm.DefaultCenter.Print(version()) - for _, l := range license { - pterm.DefaultCenter.Print(l) - } - } + pterm.Info.Printf("Luet %s\n", version()) + pterm.Info.Println(strings.Join(license, "\n")) } } diff --git a/pkg/api/core/logger/logger.go b/pkg/api/core/logger/logger.go index 2fc162e1..13bec434 100644 --- a/pkg/api/core/logger/logger.go +++ b/pkg/api/core/logger/logger.go @@ -334,7 +334,7 @@ func (l *Logger) Spinner() { } func (l *Logger) Screen(text string) { - pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(2).Println(text) + l.Infof(":::> %s", text) } func (l *Logger) SpinnerText(suffix, prefix string) {