remove unnecessary String() implementation
parent
6d507fbcd1
commit
984f563e21
|
|
@ -71,10 +71,7 @@ func HasStyle(style StyleEnum) bool {
|
|||
|
||||
// OutStyle writes a stylized and formatted message to stdout
|
||||
func OutStyle(style StyleEnum, format string, a ...interface{}) {
|
||||
outStyled, err := applyStyle(style, useColor, format, a...)
|
||||
if err != nil {
|
||||
glog.Errorf("applyStyle(%s): %v", style, err)
|
||||
}
|
||||
outStyled := applyStyle(style, useColor, format, a...)
|
||||
|
||||
// escape any outstanding '%' signs so that they don't get interpreted
|
||||
// as a formatting directive down the line
|
||||
|
|
@ -102,11 +99,7 @@ func OutLn(format string, a ...interface{}) {
|
|||
|
||||
// ErrStyle writes a stylized and formatted error message to stderr
|
||||
func ErrStyle(style StyleEnum, format string, a ...interface{}) {
|
||||
format, err := applyStyle(style, useColor, format, a...)
|
||||
if err != nil {
|
||||
glog.Errorf("applyStyle(%s): %v", style, err)
|
||||
ErrLn(format, a...)
|
||||
}
|
||||
format = applyStyle(style, useColor, format, a...)
|
||||
|
||||
// escape any outstanding '%' signs so that they don't get interpreted
|
||||
// as a formatting directive down the line
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func TestOutStyle(t *testing.T) {
|
|||
}
|
||||
for _, tc := range tests {
|
||||
for _, override := range []bool{true, false} {
|
||||
t.Run(fmt.Sprintf("%s-override-%v", tc.style, override), func(t *testing.T) {
|
||||
t.Run(fmt.Sprintf("%s-override-%v", tc.message, override), func(t *testing.T) {
|
||||
// Set MINIKUBE_IN_STYLE=<override>
|
||||
os.Setenv(OverrideEnv, strconv.FormatBool(override))
|
||||
f := newFakeFile()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package console
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/message"
|
||||
|
|
@ -136,7 +135,7 @@ func lowPrefix(s style) string {
|
|||
}
|
||||
|
||||
// Apply styling to a format string
|
||||
func applyStyle(style StyleEnum, useColor bool, format string, a ...interface{}) (string, error) {
|
||||
func applyStyle(style StyleEnum, useColor bool, format string, a ...interface{}) string {
|
||||
p := message.NewPrinter(preferredLanguage)
|
||||
for i, x := range a {
|
||||
if _, ok := x.(int); ok {
|
||||
|
|
@ -152,11 +151,11 @@ func applyStyle(style StyleEnum, useColor bool, format string, a ...interface{})
|
|||
|
||||
// Similar to CSS styles, if no style matches, output an unformatted string.
|
||||
if !ok {
|
||||
return p.Sprintf(format, a...), fmt.Errorf("unknown style: %q", style)
|
||||
return p.Sprintf(format, a...)
|
||||
}
|
||||
|
||||
if !useColor {
|
||||
return applyPrefix(lowPrefix(s), out), nil
|
||||
return applyPrefix(lowPrefix(s), out)
|
||||
}
|
||||
return applyPrefix(s.Prefix, out), nil
|
||||
return applyPrefix(s.Prefix, out)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,70 +78,3 @@ const (
|
|||
MountOptions
|
||||
Fileserver
|
||||
)
|
||||
|
||||
func (style StyleEnum) String() string {
|
||||
var s = []string{"Happy",
|
||||
"SuccessType",
|
||||
"FailureType",
|
||||
"Conflict",
|
||||
"FatalType",
|
||||
"Notice",
|
||||
"Ready",
|
||||
"Running",
|
||||
"Provisioning",
|
||||
"Restarting",
|
||||
"Reconfiguring",
|
||||
"Stopping",
|
||||
"Stopped",
|
||||
"WarningType",
|
||||
"Waiting",
|
||||
"WaitingPods",
|
||||
"Usage",
|
||||
"Launch",
|
||||
"Sad",
|
||||
"ThumbsUp",
|
||||
"Option",
|
||||
"Command",
|
||||
"LogEntry",
|
||||
"Crushed",
|
||||
"URL",
|
||||
"Documentation",
|
||||
"Issues",
|
||||
"Issue",
|
||||
"Check",
|
||||
"IsoDownload",
|
||||
"FileDownload",
|
||||
"Caching",
|
||||
"StartingVM",
|
||||
"StartingNone",
|
||||
"Resetting",
|
||||
"DeletingHost",
|
||||
"Copying",
|
||||
"Connectivity",
|
||||
"Internet",
|
||||
"Mounting",
|
||||
"Celebrate",
|
||||
"ContainerRuntime",
|
||||
"Docker",
|
||||
"Crio",
|
||||
"Containerd",
|
||||
"Permissions",
|
||||
"Enabling",
|
||||
"Shutdown",
|
||||
"Pulling",
|
||||
"Verifying",
|
||||
"VerifyingNoLine",
|
||||
"Kubectl",
|
||||
"Meh",
|
||||
"Embarrassed",
|
||||
"Tip",
|
||||
"Unmount",
|
||||
"MountOptions",
|
||||
"Fileserver"}
|
||||
|
||||
if style > Fileserver {
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
return s[style]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue