-
Notifications
You must be signed in to change notification settings - Fork 216
/
Copy pathcolors.go
56 lines (43 loc) · 1.48 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package output
import (
"fmt"
"github.com/fatih/color"
)
// withLinkFormat creates string with hyperlink-looking color
func WithLinkFormat(link string, a ...interface{}) string {
return color.HiCyanString(link, a...)
}
// withHighLightFormat creates string with highlight-looking color
func WithHighLightFormat(text string, a ...interface{}) string {
return color.HiBlueString(text, a...)
}
func WithErrorFormat(text string, a ...interface{}) string {
return color.RedString(text, a...)
}
func WithWarningFormat(text string, a ...interface{}) string {
return color.YellowString(text, a...)
}
func WithSuccessFormat(text string, a ...interface{}) string {
return color.GreenString(text, a...)
}
func WithGrayFormat(text string, a ...interface{}) string {
return color.HiBlackString(text, a...)
}
func WithBold(text string, a ...interface{}) string {
format := color.New(color.Bold)
return format.Sprintf(text, a...)
}
func WithUnderline(text string, a ...interface{}) string {
format := color.New(color.Underline)
return format.Sprintf(text, a...)
}
// WithBackticks wraps text with the backtick (`) character.
func WithBackticks(text string) string {
return "`" + text + "`"
}
// WithHyperlink wraps text with the colored hyperlink format escape sequence.
func WithHyperlink(url string, text string) string {
return WithLinkFormat(fmt.Sprintf("\033]8;;%s\007%s\033]8;;\007", url, text))
}