Use basic ui if using a non color enabled terminal

This commit is contained in:
sophia 2022-09-13 11:45:33 -04:00
parent f7cd08b208
commit 21e9fc3674

View File

@ -182,6 +182,9 @@ func BaseCommand(ctx context.Context, log hclog.Logger, logOutput io.Writer, opt
} else if !bc.flagInteractive {
// Set non interactive if the --no-interactive flag is provided
ui = terminal.NonInteractiveUI(ctx)
} else if !bc.flagColor {
// Set basic ui (with no color) if the --no-color flag is provided
ui = terminal.BasicUI(ctx)
} else {
// If no ui related flags are set, create a new one
ui = terminal.ConsoleUI(ctx)
@ -331,6 +334,9 @@ func (c *baseCommand) Init(opts ...Option) (err error) {
} else if !c.flagInteractive {
// Set non interactive if the --no-interactive flag is provided
ui = terminal.NonInteractiveUI(c.Ctx)
} else if !c.flagColor {
// Set basic ui (with no color) if the --no-color flag is provided
ui = terminal.BasicUI(c.Ctx)
} else {
// If no ui related flags are set, use the base config ui
ui = baseCfg.UI