|
| 1 | +package cmd |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/fatih/color" |
| 5 | + "fmt" |
| 6 | +) |
| 7 | + |
| 8 | +var( |
| 9 | + mainColor = color.BgBlue |
| 10 | + secColor = color.BgYellow |
| 11 | + mainTxt = color.New(color.FgHiWhite, color.BgBlack, color.Bold) |
| 12 | + mainTxtSprint = mainTxt.SprintFunc() |
| 13 | + mainTxtColor = mainTxt.SprintfFunc() |
| 14 | + secTxtColor = color.New(color.FgWhite, color.BgBlack, color.Faint).SprintfFunc() |
| 15 | + mainTxtBlink = color.New(color.FgHiWhite, color.BgBlack, color.Bold, color.BlinkSlow).SprintfFunc() |
| 16 | + mainTitle = color.New(color.FgHiWhite, mainColor, color.Bold) |
| 17 | + mainTitleColor = mainTitle.SprintfFunc() |
| 18 | + mainTitlePrint = mainTitle.SprintFunc() |
| 19 | + secTitleColor = color.New(color.FgBlack, secColor, color.Bold).SprintfFunc() |
| 20 | + secTitleBlink = color.New(color.FgBlack, secColor, color.Bold, color.BlinkSlow).SprintfFunc() |
| 21 | + whiteSpace = " " |
| 22 | + whiteSpaceDash = " - " |
| 23 | +) |
| 24 | + |
| 25 | +func mainTxtPrintln(body ...interface{}){ fmt.Println(mainTxtSprint(body...)) } |
| 26 | +func colorfulPrintln(body ...interface{}){ fmt.Println(mainTitlePrint(body...)) } |
| 27 | +func colorfulPrint(body ...interface{}){ fmt.Print(mainTitlePrint(body...)) } |
| 28 | + |
| 29 | +func printKeyVal(space, k, v string){ |
| 30 | + fmt.Printf("%s:%s \r\n", |
| 31 | + mainTxtColor(" %s%s ", space, k), |
| 32 | + secTxtColor(" %s ", v)) |
| 33 | +} |
| 34 | + |
| 35 | +func printTitleByStatus(space, title, status string){ |
| 36 | + if status == "Unreachable" { |
| 37 | + fmt.Printf("%s%s:%s\r\n", |
| 38 | + space, |
| 39 | + secTitleColor(" %s ", title), |
| 40 | + secTitleBlink(" # [Unreachable] ")) |
| 41 | + } else { |
| 42 | + fmt.Printf("%s%s:\r\n", |
| 43 | + space, |
| 44 | + mainTitleColor(" %s ", title)) |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +func printTitle(space, title string){ |
| 49 | + fmt.Printf("%s%s:\r\n", |
| 50 | + space, |
| 51 | + mainTitleColor(" %s ", title)) |
| 52 | +} |
0 commit comments