-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhobocode.go
47 lines (38 loc) · 1.08 KB
/
hobocode.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
/*
package hobocode provides some lazy convenience functions
for wrapping text in colors, detecting tty, terminal
size, and colored/formatted interactive inputs
The coloring choices are opinionated and the "levels" are based
on common logging patterns but with a focus on Console UX vs. logging style
Note: Most of the printers in this library automatically
new-line fields with Println variants
*/
package hobocode
import (
"fmt"
"os"
)
// Stdoutln prints with newline to os.Stdout
func Stdoutln(message string) {
Stdlin(os.Stdout, message)
}
// Stderrln prints with newline to os.Stderr
func Stderrln(message string) {
Stdlin(os.Stderr, message)
}
// Stdout prints without newline to os.Stdout
func Stdout(message string) {
Std(os.Stdout, message)
}
// Stderr prints without newline to os.Stdout
func Stderr(message string) {
Std(os.Stderr, message)
}
// Stdlin prints with newline to *os.File the given message
func Stdlin(fd *os.File, message string) {
fmt.Fprintln(fd, message)
}
// Std prints without newline to *os.FIle
func Std(fd *os.File, message string) {
fmt.Fprint(fd, message)
}