Skip to content

Instantly share code, notes, and snippets.

@aduis
Created June 3, 2016 05:13
Show Gist options
  • Save aduis/fcdb0cf2934d4a6ab7f2b3190a5e5dab to your computer and use it in GitHub Desktop.
Save aduis/fcdb0cf2934d4a6ab7f2b3190a5e5dab to your computer and use it in GitHub Desktop.
watch console golang
package main
import (
"fmt"
"time"
"github.com/gosuri/uilive"
"github.com/ttacon/chalk"
)
func main() {
writer := uilive.New()
// start listening for updates and render
writer.Start()
dots := ""
jenkins := "not set up"
gitlab := "not set up"
kubernetes := "not set up"
for i := 0; i <= 500000; i++ {
if i == 10 {
jenkins = "green"
gitlab = "http://git.cgn.cleverbridge.com"
kubernetes = "http://devkub-node1.cgn.cleverbridge.com:32099"
}
fmt.Fprintf(writer, chalk.Bold.TextStyle("appyard"))
fmt.Fprintf(writer, " - status\n\n")
fmt.Fprintf(writer, "watching for updates \t%s%s%s\n", chalk.Cyan, dots, chalk.Reset)
fmt.Fprintf(writer, "=======================================================\n")
fmt.Fprintf(writer, "Jenkins status: \t%s%s%s\n", chalk.Cyan, jenkins, chalk.Reset)
fmt.Fprintf(writer, "Gitlab url: \t\t%s%s%s\n", chalk.Cyan, chalk.Underline.TextStyle(gitlab), chalk.Reset)
fmt.Fprintf(writer, "=======================================================\n")
fmt.Fprintf(writer, "Kubernetes status: \t%s%s%s\n", chalk.Cyan, chalk.Underline.TextStyle(kubernetes), chalk.Reset)
if dots == "..........................." {
dots = ""
}
dots += "."
time.Sleep(time.Millisecond * 1000)
}
writer.Stop() // flush and stop rendering
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment