Esempio n. 1
0
func RenderErrorSummary(s *models.Stage) {
	titleLine := fmt.Sprintf("Found following errors:")
	fmt.Printf("\n")
	fmt.Printf(tm.Bold(titleLine))
	fmt.Printf("\n")
	fmt.Printf("\n")
	_ = "breakpoint"
	for _, n := range s.Nodes {
		if n.HasError() {
			fmt.Printf(tm.Color(tm.Bold(n.Fqdn), tm.RED))
			fmt.Printf("\n")
			for _, e := range n.Errors {
				ErrorString := fmt.Sprintf("%v", e.Error())
				fmt.Printf(" - ")
				fmt.Printf(tm.Color(ErrorString, tm.RED))
				fmt.Printf("\n")
			}
			for k, v := range n.RepositoryError {
				reposiroryErrorString := fmt.Sprintf("%v: ", k)
				fmt.Printf(" - ")
				fmt.Printf(tm.Color(reposiroryErrorString, tm.RED))
				fmt.Printf(v.Error())
				fmt.Printf("\n")
			}
			fmt.Printf("\n")
		}
	}
}
Esempio n. 2
0
File: main.go Progetto: rmg/tyk
// Display introductory details
func intro() {
	fmt.Print("\n\n")
	fmt.Println(goterm.Bold(goterm.Color("Tyk.io Gateway API v1.0", goterm.GREEN)))
	fmt.Println(goterm.Bold(goterm.Color("=======================", goterm.GREEN)))
	fmt.Print("Copyright Jively Ltd. 2014")
	fmt.Print("\nhttp://www.tyk.io\n\n")
}
Esempio n. 3
0
func GetText(message string, defaultText string) string {
	fmt.Printf("%s", goterm.Color(goterm.Bold(message), goterm.GREEN))

	if defaultText != "" {
		fmt.Printf(" %s%s%s",
			goterm.Color(goterm.Bold("["), goterm.GREEN),
			goterm.Color(defaultText, goterm.YELLOW),
			goterm.Color(goterm.Bold("]"), goterm.GREEN))
	}

	fmt.Printf("%s ", goterm.Color(goterm.Bold(":"), goterm.GREEN))

	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')

	if text[len(text)-1] == '\n' {
		text = text[:len(text)-1]
	}

	if text == "" {
		text = defaultText
	}

	return text
}
Esempio n. 4
0
func printHosts(lastApiResponse *healthd.ApiResponseHosts, status *healthdStatus) {
	goterm.Clear() // Clear current screen
	goterm.MoveCursor(1, 1)
	defer goterm.Flush()
	goterm.Println("Current Time:", status.FmtNow(), "   Status:", status.FmtStatus())

	//
	if lastApiResponse == nil {
		goterm.Println("no data yet")
		return
	}

	columns := []string{
		"Host:Port",
		"Status",
		"Last Checked",
		"Last Response Time",
	}

	for i, s := range columns {
		columns[i] = goterm.Bold(goterm.Color(s, goterm.BLACK))
	}

	table := goterm.NewTable(0, goterm.Width()-1, 5, ' ', 0)
	fmt.Fprintf(table, "%s\n", strings.Join(columns, "\t"))

	for _, host := range lastApiResponse.Hosts {
		printHost(table, host)
	}

	goterm.Println(table)
}
Esempio n. 5
0
func format(text string, color int, isBold bool) string {
	if isBold {
		return goterm.Bold(goterm.Color(text, color))
	} else {
		return normal(goterm.Color(text, color))
	}

}
Esempio n. 6
0
// simple view. No in place updates
func RenderQuietView(progressChannel chan models.SyncProgress, wg *sync.WaitGroup) {
	depthChar := "--- "
	defer wg.Done()
	syncStates := make(map[string]map[string]string)
	for sp := range progressChannel {
		if _, exists := syncStates[sp.Node.Fqdn]; !exists {
			syncStates[sp.Node.Fqdn] = make(map[string]string)
		}
		switch sp.State {
		case "skipped":
			for i := 0; i < sp.Node.Depth; i++ {
				fmt.Printf(depthChar)
			}
			line := fmt.Sprintf("%v %v %v", sp.Node.Fqdn, sp.Repository, sp.State)
			tm.Printf(tm.Color(tm.Bold(line), tm.MAGENTA))
			tm.Flush()
		case "error":
			for i := 0; i < sp.Node.Depth; i++ {
				fmt.Printf(depthChar)
			}
			line := fmt.Sprintf("%v %v %v", sp.Node.Fqdn, sp.Repository, sp.State)
			tm.Printf(tm.Color(tm.Bold(line), tm.RED))
			tm.Flush()
		case "running":
			// only output state changes
			if syncStates[sp.Node.Fqdn][sp.Repository] != sp.State {
				for i := 0; i < sp.Node.Depth; i++ {
					fmt.Printf(depthChar)
				}
				line := fmt.Sprintf("%v %v %v", sp.Node.Fqdn, sp.Repository, sp.State)
				tm.Printf(tm.Color(line, tm.BLUE))
				tm.Flush()
			}
			syncStates[sp.Node.Fqdn][sp.Repository] = sp.State
		case "finished":
			for i := 0; i < sp.Node.Depth; i++ {
				fmt.Printf(depthChar)
			}
			line := fmt.Sprintf("%v %v %v", sp.Node.Fqdn, sp.Repository, sp.State)
			tm.Printf(tm.Color(tm.Bold(line), tm.GREEN))
			tm.Flush()
		}
	}
}
Esempio n. 7
0
func (m *Menu) Render() {
	if m.Heading != "" {
		fmt.Println(m.Heading)
	}

	fmt.Printf("%s\n", goterm.Color(goterm.Bold(m.Question)+":", goterm.GREEN))

	m.DrawMenuItems(false)

	// Hide cursor.
	fmt.Printf("\033[?25l")
}
Esempio n. 8
0
func printJobs(lastApiResponse *healthd.ApiResponseJobs, status *healthdStatus) {
	goterm.Clear() // Clear current screen
	goterm.MoveCursor(1, 1)
	defer goterm.Flush()
	goterm.Println("Current Time:", status.FmtNow(), "   Status:", status.FmtStatus())

	if lastApiResponse == nil {
		goterm.Println("no data yet")
		return
	}

	columns := []string{
		"Job",
		//		"Jobs/Second", //minute? flag?
		"Total Count",
		"Success",
		"ValidationError",
		"Panic",
		"Error",
		"Junk",
		"Avg Response Time",
		"Stddev",
		"Min",
		"Max",
		"Total",
	}

	for i, s := range columns {
		columns[i] = goterm.Bold(goterm.Color(s, goterm.BLACK))
	}

	table := goterm.NewTable(0, goterm.Width()-1, 5, ' ', 0)
	fmt.Fprintf(table, "%s\n", strings.Join(columns, "\t"))

	for _, job := range lastApiResponse.Jobs {
		printJob(table, job)
	}

	goterm.Println(table)
}