mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-28 01:41:48 -06:00
ffe056bacb
This is part of a general effort to move all of Terraform's non-library package surface under internal in order to reinforce that these are for internal use within Terraform only. If you were previously importing packages under this prefix into an external codebase, you could pin to an earlier release tag as an interim solution until you've make a plan to achieve the same functionality some other way.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mitchellh/cli"
|
|
"github.com/mitchellh/colorstring"
|
|
)
|
|
|
|
// ColoredUi is a Ui implementation that colors its output according
|
|
// to the given color schemes for the given type of output.
|
|
type ColorizeUi struct {
|
|
Colorize *colorstring.Colorize
|
|
OutputColor string
|
|
InfoColor string
|
|
ErrorColor string
|
|
WarnColor string
|
|
Ui cli.Ui
|
|
}
|
|
|
|
func (u *ColorizeUi) Ask(query string) (string, error) {
|
|
return u.Ui.Ask(u.colorize(query, u.OutputColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) AskSecret(query string) (string, error) {
|
|
return u.Ui.AskSecret(u.colorize(query, u.OutputColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) Output(message string) {
|
|
u.Ui.Output(u.colorize(message, u.OutputColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) Info(message string) {
|
|
u.Ui.Info(u.colorize(message, u.InfoColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) Error(message string) {
|
|
u.Ui.Error(u.colorize(message, u.ErrorColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) Warn(message string) {
|
|
u.Ui.Warn(u.colorize(message, u.WarnColor))
|
|
}
|
|
|
|
func (u *ColorizeUi) colorize(message string, color string) string {
|
|
if color == "" {
|
|
return message
|
|
}
|
|
|
|
return u.Colorize.Color(fmt.Sprintf("%s%s[reset]", color, message))
|
|
}
|