Setup noninteractive ui for the base command if the --no-tty falg is provided
This commit is contained in:
parent
7a999d1f06
commit
26fac3e1d9
@ -147,12 +147,8 @@ func BaseCommand(ctx context.Context, log hclog.Logger, logOutput io.Writer, opt
|
||||
opt(c)
|
||||
}
|
||||
|
||||
if c.UI == nil {
|
||||
c.UI = terminal.ConsoleUI(context.Background())
|
||||
}
|
||||
|
||||
if c.Args, err = bc.Parse(c.Flags, c.Args, true); err != nil {
|
||||
c.UI.Output(clierrors.Humanize(err), terminal.WithErrorStyle())
|
||||
log.Error(clierrors.Humanize(err))
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -162,6 +158,17 @@ func BaseCommand(ctx context.Context, log hclog.Logger, logOutput io.Writer, opt
|
||||
bc.flagBasis = "default"
|
||||
}
|
||||
|
||||
// Set UI
|
||||
var ui terminal.UI
|
||||
// Set non interactive if the --no-tty flag is provided
|
||||
if !bc.flagTTY {
|
||||
ui = terminal.NonInteractiveUI(ctx)
|
||||
} else {
|
||||
// If no ui related flags are set, create a new one
|
||||
ui = terminal.ConsoleUI(ctx)
|
||||
}
|
||||
bc.ui = ui
|
||||
|
||||
homeConfigPath, err := paths.NamedVagrantConfig(bc.flagBasis)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user