mirror of
https://github.com/mudler/luet.git
synced 2025-04-28 03:30:09 +00:00
🔧 CLI: add quiet mode
This commit is contained in:
parent
79e98af604
commit
1e6aca0ba1
@ -371,6 +371,10 @@ Search can also return results in the terminal in different ways: as terminal ou
|
||||
default:
|
||||
if tableMode {
|
||||
t.Render()
|
||||
} else if util.DefaultContext.Config.General.Quiet {
|
||||
for _, tt := range results.Packages {
|
||||
fmt.Printf("%s/%s-%s\n", tt.Category, tt.Name, tt.Version)
|
||||
}
|
||||
} else {
|
||||
l.Render()
|
||||
}
|
||||
|
@ -156,11 +156,15 @@ func DisplayVersionBanner(c *types.Context, banner func(), version func() string
|
||||
}
|
||||
}
|
||||
if display {
|
||||
banner()
|
||||
pterm.DefaultCenter.Print(version())
|
||||
for _, l := range license {
|
||||
pterm.DefaultCenter.Print(l)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,7 @@ func setDefaults(viper *viper.Viper) {
|
||||
|
||||
viper.SetDefault("general.concurrency", runtime.NumCPU())
|
||||
viper.SetDefault("general.debug", false)
|
||||
viper.SetDefault("general.quiet", false)
|
||||
viper.SetDefault("general.show_build_output", false)
|
||||
viper.SetDefault("general.fatal_warnings", false)
|
||||
viper.SetDefault("general.http_timeout", 360)
|
||||
@ -159,7 +160,8 @@ func InitViper(ctx *types.Context, RootCmd *cobra.Command) {
|
||||
cobra.OnInitialize(initConfig)
|
||||
pflags := RootCmd.PersistentFlags()
|
||||
pflags.StringVar(&cfgFile, "config", "", "config file (default is $HOME/.luet.yaml)")
|
||||
pflags.BoolP("debug", "d", false, "verbose output")
|
||||
pflags.BoolP("debug", "d", false, "debug output")
|
||||
pflags.BoolP("quiet", "q", false, "quiet output")
|
||||
pflags.Bool("fatal", false, "Enables Warnings to exit")
|
||||
pflags.Bool("enable-logfile", false, "Enable log to file")
|
||||
pflags.Bool("no-spinner", false, "Disable spinner.")
|
||||
@ -188,6 +190,7 @@ func InitViper(ctx *types.Context, RootCmd *cobra.Command) {
|
||||
|
||||
viper.BindPFlag("general.concurrency", pflags.Lookup("concurrency"))
|
||||
viper.BindPFlag("general.debug", pflags.Lookup("debug"))
|
||||
viper.BindPFlag("general.quiet", pflags.Lookup("quiet"))
|
||||
viper.BindPFlag("general.fatal_warnings", pflags.Lookup("fatal"))
|
||||
viper.BindPFlag("general.same_owner", pflags.Lookup("same-owner"))
|
||||
viper.BindPFlag("plugin", pflags.Lookup("plugin"))
|
||||
|
@ -61,6 +61,7 @@ type LuetGeneralConfig struct {
|
||||
ShowBuildOutput bool `yaml:"show_build_output,omitempty" mapstructure:"show_build_output"`
|
||||
FatalWarns bool `yaml:"fatal_warnings,omitempty" mapstructure:"fatal_warnings"`
|
||||
HTTPTimeout int `yaml:"http_timeout,omitempty" mapstructure:"http_timeout"`
|
||||
Quiet bool `yaml:"quiet" mapstructure:"quiet"`
|
||||
}
|
||||
|
||||
type LuetSolverOptions struct {
|
||||
|
@ -112,6 +112,11 @@ func (c *Context) Init() (err error) {
|
||||
c.NoColor()
|
||||
}
|
||||
|
||||
if c.Config.General.Quiet {
|
||||
c.NoColor()
|
||||
pterm.DisableStyling()
|
||||
}
|
||||
|
||||
c.Debug("Colors", c.Config.GetLogging().Color)
|
||||
c.Debug("Logging level", c.Config.GetLogging().Level)
|
||||
c.Debug("Debug mode", c.Config.GetGeneral().Debug)
|
||||
|
Loading…
Reference in New Issue
Block a user