@@ -56,21 +56,28 @@ func Log(err error) {
56
56
fmt .Fprintln (os .Stderr , cliErr .String ())
57
57
}
58
58
59
- // Info formats according to a format specifier and prints the resulting CLI message.
60
- func Info ( format string , args ... interface {} ) {
59
+ // LogInfo prints the given info message to stderr .
60
+ func LogInfo ( header string , lines ... string ) {
61
61
fmt .Fprintln (os .Stderr , RichCLIMessage {
62
62
Level : "info" ,
63
63
Color : color .FgBlue ,
64
- Header : fmt .Sprintf (format , args ... ),
64
+ Header : header ,
65
+ Lines : lines ,
65
66
}.String ())
66
67
}
67
68
68
- // Success formats according to a format specifier and prints the resulting CLI message.
69
- func Success (format string , args ... interface {}) {
69
+ // F formats according to a format specifier and resturns the resulting string.
70
+ func F (format string , a ... interface {}) string {
71
+ return fmt .Sprintf (format , a ... )
72
+ }
73
+
74
+ // LogSuccess prints the given info message to stderr.
75
+ func LogSuccess (header string , lines ... string ) {
70
76
fmt .Fprintln (os .Stderr , RichCLIMessage {
71
77
Level : "success" ,
72
78
Color : color .FgGreen ,
73
- Header : fmt .Sprintf (format , args ... ),
79
+ Header : header ,
80
+ Lines : lines ,
74
81
}.String ())
75
82
}
76
83
@@ -117,3 +124,18 @@ func Fatal(header string, lines ...string) RichCLIError {
117
124
func Bold (a string ) string {
118
125
return color .New (color .Bold ).Sprint (a )
119
126
}
127
+
128
+ // Tip formats according to the given format specifier and prepends a bolded "tip: " header.
129
+ func Tip (format string , a ... interface {}) string {
130
+ return fmt .Sprintf ("%s %s" , Bold ("tip:" ), fmt .Sprintf (format , a ... ))
131
+ }
132
+
133
+ // Hint formats according to the given format specifier and prepends a bolded "hint: " header.
134
+ func Hint (format string , a ... interface {}) string {
135
+ return fmt .Sprintf ("%s %s" , Bold ("hint:" ), fmt .Sprintf (format , a ... ))
136
+ }
137
+
138
+ // Cause formats according to the given format specifier and prepends a bolded "Cause: " header.
139
+ func Cause (format string , a ... interface {}) string {
140
+ return fmt .Sprintf ("%s %s" , Bold ("cause:" ), fmt .Sprintf (format , a ... ))
141
+ }
0 commit comments