add format management for command-line commands
This commit is contained in:
parent
f0aa6d2c5c
commit
fb169b0a10
|
@ -0,0 +1,13 @@
|
|||
package clifmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Color(color byte, s string, bold ...bool) string {
|
||||
b := "0"
|
||||
if len(bold) > 0 && bold[0] {
|
||||
b = "1"
|
||||
}
|
||||
return fmt.Sprintf("\033[%s;%dm%s\033[0m", b, color, s)
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package clifmt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func Warn(s ...string) string {
|
||||
if len(s) == 0 {
|
||||
return Color(31, "/!\\")
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s %s", Warn(), s[0])
|
||||
}
|
||||
func Info(s ...string) string {
|
||||
if len(s) == 0 {
|
||||
return Color(34, "(!)")
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s %s", Info(), s[0])
|
||||
}
|
Loading…
Reference in New Issue