forked from tn47/goledger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colors.go
63 lines (57 loc) · 1.33 KB
/
colors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package api
import (
"fmt"
"github.com/pschlump/MiscLib"
)
//
//import (
// "fmt"
// "os"
//
// "github.com/pschlump/MiscLib"
// "github.com/pschlump/godebug"
//)
//
//type ColorAttribute int
//
//const (
// FgYellow ColorAttribute = 1
// FgRed ColorAttribute = 2
//)
//
//func Color(fg ColorAttribute, s string) fmt.Formatter {
// switch fg {
// case FgYellow:
// return fmt.Sprintf("%s%s%s", MiscLib.ColorYellow, s, MiscLib.ColorReset)
// case FgRed:
// return fmt.Sprintf("%s%s%s", MiscLib.ColorRed, s, MiscLib.ColorReset)
// }
// fmt.Fprintf(os.Stderr, "Invalid case in Color: AT%s\n", godebug.LF(-5))
// return s
// // panic("unreachable code - impossible situation")
//}
//PJS -- missing library
//
//import "fmt"
//
//import "github.com/pschlump/color"
//
//var YellowFn = color.New(color.FgYellow).FormatFunc()
//var RedFn = color.New(color.FgRed).FormatFunc()
//
//func Color(fg color.Attribute, s string) fmt.Formatter {
// switch fg {
// case color.FgYellow:
// return YellowFn(s)
// case color.FgRed:
// return RedFn(s)
// }
// panic("impossible situation")
//}
// See: https://blog.gopheracademy.com/advent-2018/fmt/
func YellowFn(s string) string {
return fmt.Sprintf("%s%s%s", MiscLib.ColorYellow, s, MiscLib.ColorReset)
}
func RedFn(s string) string {
return fmt.Sprintf("%s%s%s", MiscLib.ColorRed, s, MiscLib.ColorReset)
}