Exemple #1
0
func (cmd *Command) overviewAction(backendId string, watch int, limit int) {
	var bk *engine.BackendKey
	if backendId != "" {
		bk = &engine.BackendKey{Id: backendId}
	}
	for {
		frontends, err := cmd.client.TopFrontends(bk, limit)
		if err != nil {
			cmd.printError(err)
			frontends = []engine.Frontend{}
		}

		servers, err := cmd.client.TopServers(bk, limit)
		if err != nil {
			cmd.printError(err)
			servers = []engine.Server{}
		}
		t := time.Now()
		if watch != 0 {
			goterm.Clear()
			goterm.MoveCursor(1, 1)
			goterm.Flush()
			fmt.Fprintf(cmd.out, "%s Every %d seconds. Top %d entries\n\n", t.Format("2006-01-02 15:04:05"), watch, limit)
		}
		cmd.printOverview(frontends, servers)
		if watch != 0 {
			goterm.Flush()
		} else {
			return
		}
		time.Sleep(time.Second * time.Duration(watch))
	}
}
Exemple #2
0
func main() {
	tm.Clear() // Clear current screen
	started := 100
	finished := 250

	// Based on http://golang.org/pkg/text/tabwriter
	totals := tm.NewTable(0, 10, 5, ' ', 0)
	fmt.Fprintf(totals, "Time\tStarted\tActive\tFinished\n")
	fmt.Fprintf(totals, "%s\t%d\t%d\t%d\n", "All", started, started-finished, finished)
	tm.Println(totals)

	tm.Flush()
}
Exemple #3
0
func main() {
	tm.Clear() // Clear current screen

	for {
		// By moving cursor to top-left position we ensure that console output
		// will be overwritten each time, instead of adding new.
		tm.MoveCursor(1, 1)

		tm.Println("Current Time:", time.Now().Format(time.RFC1123))

		tm.Flush() // Call it every time at the end of rendering

		time.Sleep(time.Second)
	}
}
Exemple #4
0
func main() {
	tm.Clear()

	// Create Box with 30% width of current screen, and height of 20 lines
	box := tm.NewBox(30|tm.PCT, 20, 0)

	// Add some content to the box
	// Note that you can add ANY content, even tables
	fmt.Fprint(box, "Some box content")

	// Move Box to approx center of the screen
	tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT))

	tm.Flush()
}
Exemple #5
0
func main() {
	tm.Clear()
	tm.MoveCursor(0, 0)

	chart := tm.NewLineChart(100, 20)
	data := new(tm.DataTable)
	data.AddColumn("Time")
	data.AddColumn("Sin(x)")
	data.AddColumn("Cos(x+1)")

	for i := 0.1; i < 10; i += 0.1 {
		data.AddRow(i, math.Sin(i), math.Cos(i+1))
	}

	tm.Println(chart.Draw(data))
	tm.Flush()
}
Exemple #6
0
func main() {
	f, err := os.Create("box.txt")
	if err != nil {
		panic("Unable to create box file!")
	}
	defer f.Close()

	// Tell tm to use the file we just opened, not stdout
	tm.Output = bufio.NewWriter(f)

	// More or less stolen from the box example
	tm.Clear()
	box := tm.NewBox(30|tm.PCT, 20, 0)
	fmt.Fprint(box, "Some box content")
	tm.Print(tm.MoveTo(box.String(), 40|tm.PCT, 40|tm.PCT))
	tm.Flush()

	fmt.Println("Now view the contents of 'box.txt' in an ansi-capable terminal")
}