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

	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 #3
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()
}