views: Use new streams helper functions
This commit is contained in:
parent
f91a3b87c1
commit
3cd086f46c
|
@ -61,7 +61,7 @@ func (v *OutputHuman) Output(name string, outputs map[string]*states.OutputValue
|
||||||
return diags
|
return diags
|
||||||
}
|
}
|
||||||
result := repl.FormatValue(output.Value, 0)
|
result := repl.FormatValue(output.Value, 0)
|
||||||
v.output(result)
|
v.streams.Println(result)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ func (v *OutputHuman) Output(name string, outputs map[string]*states.OutputValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v.output(strings.TrimSpace(outputBuf.String()))
|
v.streams.Println(strings.TrimSpace(outputBuf.String()))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ func (v *OutputJSON) Output(name string, outputs map[string]*states.OutputValue)
|
||||||
return diags
|
return diags
|
||||||
}
|
}
|
||||||
|
|
||||||
v.output(string(jsonOutput))
|
v.streams.Println(string(jsonOutput))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ func (v *OutputJSON) Output(name string, outputs map[string]*states.OutputValue)
|
||||||
return diags
|
return diags
|
||||||
}
|
}
|
||||||
|
|
||||||
v.output(string(jsonOutputs))
|
v.streams.Println(string(jsonOutputs))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package views
|
package views
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/command/arguments"
|
"github.com/hashicorp/terraform/command/arguments"
|
||||||
"github.com/hashicorp/terraform/command/format"
|
"github.com/hashicorp/terraform/command/format"
|
||||||
"github.com/hashicorp/terraform/internal/terminal"
|
"github.com/hashicorp/terraform/internal/terminal"
|
||||||
|
@ -82,7 +80,7 @@ func (v *View) Diagnostics(diags tfdiags.Diagnostics) {
|
||||||
if useCompact {
|
if useCompact {
|
||||||
msg := format.DiagnosticWarningsCompact(diags, v.colorize)
|
msg := format.DiagnosticWarningsCompact(diags, v.colorize)
|
||||||
msg = "\n" + msg + "\nTo see the full warning notes, run Terraform without -compact-warnings.\n"
|
msg = "\n" + msg + "\nTo see the full warning notes, run Terraform without -compact-warnings.\n"
|
||||||
v.output(msg)
|
v.streams.Print(msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,9 +94,9 @@ func (v *View) Diagnostics(diags tfdiags.Diagnostics) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if diag.Severity() == tfdiags.Error {
|
if diag.Severity() == tfdiags.Error {
|
||||||
fmt.Fprint(v.streams.Stderr.File, msg)
|
v.streams.Eprint(msg)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprint(v.streams.Stdout.File, msg)
|
v.streams.Print(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,16 +105,10 @@ func (v *View) Diagnostics(diags tfdiags.Diagnostics) {
|
||||||
// of their CLI arguments successfully. It refers users to the full help output
|
// of their CLI arguments successfully. It refers users to the full help output
|
||||||
// rather than rendering it directly, which can be overwhelming and confusing.
|
// rather than rendering it directly, which can be overwhelming and confusing.
|
||||||
func (v *View) HelpPrompt(command string) {
|
func (v *View) HelpPrompt(command string) {
|
||||||
fmt.Fprintf(v.streams.Stderr.File, helpPrompt, command)
|
v.streams.Eprintf(helpPrompt, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
const helpPrompt = `
|
const helpPrompt = `
|
||||||
For more help on using this command, run:
|
For more help on using this command, run:
|
||||||
terraform %s -help
|
terraform %s -help
|
||||||
`
|
`
|
||||||
|
|
||||||
// output is a shorthand for the common view operation of printing a string to
|
|
||||||
// the stdout stream, followed by a newline.
|
|
||||||
func (v *View) output(s string) {
|
|
||||||
fmt.Fprintln(v.streams.Stdout.File, s)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue