當前位置: 首頁>>代碼示例>>Golang>>正文


Golang stdcli.NewTable函數代碼示例

本文整理匯總了Golang中github.com/convox/rack/cmd/convox/stdcli.NewTable函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewTable函數的具體用法?Golang NewTable怎麽用?Golang NewTable使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewTable函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: cmdPs

func cmdPs(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	ps, err := rackClient(c).GetProcesses(app, c.Bool("stats"))

	if err != nil {
		stdcli.Error(err)
		return
	}

	if c.Bool("stats") {
		t := stdcli.NewTable("ID", "NAME", "RELEASE", "CPU", "MEM", "STARTED", "COMMAND")

		for _, p := range ps {
			t.AddRow(p.Id, p.Name, p.Release, fmt.Sprintf("%0.2f%%", p.Cpu*100), fmt.Sprintf("%0.2f%%", p.Memory*100), humanizeTime(p.Started), p.Command)
		}

		t.Print()
	} else {
		t := stdcli.NewTable("ID", "NAME", "RELEASE", "STARTED", "COMMAND")

		for _, p := range ps {
			t.AddRow(p.Id, p.Name, p.Release, humanizeTime(p.Started), p.Command)
		}

		t.Print()
	}
}
開發者ID:nicolas-brousse,項目名稱:rack,代碼行數:33,代碼來源:ps.go

示例2: cmdRackParams

func cmdRackParams(c *cli.Context) {
	system, err := rackClient(c).GetSystem()

	if err != nil {
		stdcli.Error(err)
		return
	}

	params, err := rackClient(c).ListParameters(system.Name)

	if err != nil {
		stdcli.Error(err)
		return
	}

	keys := []string{}

	for key, _ := range params {
		keys = append(keys, key)
	}

	sort.Strings(keys)

	t := stdcli.NewTable("NAME", "VALUE")

	for _, key := range keys {
		t.AddRow(key, params[key])
	}

	t.Print()
}
開發者ID:soulware,項目名稱:rack,代碼行數:31,代碼來源:rack.go

示例3: cmdBuilds

func cmdBuilds(c *cli.Context) {
	_, app, err := stdcli.DirApp(c, ".")

	if err != nil {
		stdcli.Error(err)
		return
	}

	builds, err := rackClient(c).GetBuilds(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("ID", "STATUS", "RELEASE", "STARTED", "ELAPSED", "DESC")

	for _, build := range builds {
		started := humanizeTime(build.Started)
		elapsed := stdcli.Duration(build.Started, build.Ended)

		if build.Ended.IsZero() {
			elapsed = ""
		}

		t.AddRow(build.Id, build.Status, build.Release, started, elapsed, build.Description)
	}

	t.Print()
}
開發者ID:soulware,項目名稱:rack,代碼行數:30,代碼來源:builds.go

示例4: cmdSSLList

func cmdSSLList(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	if len(c.Args()) > 0 {
		return stdcli.ExitError(fmt.Errorf("`convox ssl` does not take arguments. Perhaps you meant `convox ssl update`?"))
	}

	if c.Bool("help") {
		stdcli.Usage(c, "")
		return nil
	}

	ssls, err := rackClient(c).ListSSL(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	t := stdcli.NewTable("TARGET", "CERTIFICATE", "DOMAIN", "EXPIRES")

	for _, ssl := range *ssls {
		t.AddRow(fmt.Sprintf("%s:%d", ssl.Process, ssl.Port), ssl.Certificate, ssl.Domain, humanizeTime(ssl.Expiration))
	}

	t.Print()
	return nil
}
開發者ID:gmelika,項目名稱:rack,代碼行數:29,代碼來源:ssl.go

示例5: displayFormation

func displayFormation(c *cli.Context, app string) {
	formation, err := rackClient(c).ListFormation(app)

	if err != nil {
		stdcli.Error(err)
		return
	}

	pss, err := rackClient(c).GetProcesses(app, false)

	if err != nil {
		stdcli.Error(err)
		return
	}

	running := map[string]int{}

	for _, ps := range pss {
		if ps.Id != "pending" {
			running[ps.Name] += 1
		}
	}

	t := stdcli.NewTable("NAME", "DESIRED", "RUNNING", "MEMORY")

	for _, f := range formation {
		t.AddRow(f.Name, fmt.Sprintf("%d", f.Count), fmt.Sprintf("%d", running[f.Name]), fmt.Sprintf("%d", f.Memory))
	}

	t.Print()

}
開發者ID:soulware,項目名稱:rack,代碼行數:32,代碼來源:scale.go

示例6: cmdAppParams

func cmdAppParams(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.ExitError(err)
	}

	params, err := rackClient(c).ListParameters(app)
	if err != nil {
		return stdcli.ExitError(err)
	}

	keys := []string{}

	for key, _ := range params {
		keys = append(keys, key)
	}

	sort.Strings(keys)

	t := stdcli.NewTable("NAME", "VALUE")

	for _, key := range keys {
		t.AddRow(key, params[key])
	}

	t.Print()
	return nil
}
開發者ID:gmelika,項目名稱:rack,代碼行數:28,代碼來源:apps.go

示例7: cmdInstancesList

func cmdInstancesList(c *cli.Context) error {
	if len(c.Args()) > 0 {
		return stdcli.ExitError(fmt.Errorf("`convox instances` does not take arguments. Perhaps you meant `convox instances ssh`?"))
	}

	if c.Bool("help") {
		stdcli.Usage(c, "")
		return nil
	}

	instances, err := rackClient(c).GetInstances()
	if err != nil {
		return stdcli.ExitError(err)
	}

	t := stdcli.NewTable("ID", "AGENT", "STATUS", "STARTED", "PS", "CPU", "MEM")

	for _, i := range instances {
		agent := "off"
		if i.Agent {
			agent = "on"
		}

		t.AddRow(i.Id, agent, i.Status,
			humanizeTime(i.Started),
			strconv.Itoa(i.Processes),
			fmt.Sprintf("%0.2f%%", i.Cpu*100),
			fmt.Sprintf("%0.2f%%", i.Memory*100))
	}

	t.Print()
	return nil
}
開發者ID:gmelika,項目名稱:rack,代碼行數:33,代碼來源:instances.go

示例8: displayProcesses

func displayProcesses(ps []client.Process, showApp bool) {
	var t *stdcli.Table
	if showApp {
		t = stdcli.NewTable("ID", "APP", "NAME", "RELEASE", "STARTED", "COMMAND")
	} else {
		t = stdcli.NewTable("ID", "NAME", "RELEASE", "STARTED", "COMMAND")
	}

	for _, p := range ps {
		if showApp {
			t.AddRow(prettyId(p), p.App, p.Name, p.Release, humanizeTime(p.Started), p.Command)
		} else {
			t.AddRow(prettyId(p), p.Name, p.Release, humanizeTime(p.Started), p.Command)
		}
	}

	t.Print()
}
開發者ID:convox,項目名稱:rack,代碼行數:18,代碼來源:ps.go

示例9: displayProcesses

func displayProcesses(ps []client.Process) {
	t := stdcli.NewTable("ID", "NAME", "RELEASE", "STARTED", "COMMAND")

	for _, p := range ps {
		t.AddRow(prettyId(p), p.Name, p.Release, humanizeTime(p.Started), p.Command)
	}

	t.Print()
}
開發者ID:gmelika,項目名稱:rack,代碼行數:9,代碼來源:ps.go

示例10: displayProcessesStats

func displayProcessesStats(ps []client.Process, fm client.Formation) {
	t := stdcli.NewTable("ID", "NAME", "RELEASE", "CPU %", "MEM", "MEM %", "STARTED", "COMMAND")

	for _, p := range ps {
		for _, f := range fm {
			if f.Name != p.Name {
				continue
			}
			t.AddRow(prettyId(p), p.Name, p.Release, fmt.Sprintf("%0.2f%%", p.Cpu), fmt.Sprintf("%0.1fMB/%dMB", p.Memory*float64(f.Memory), f.Memory), fmt.Sprintf("%0.2f%%", p.Memory*100), humanizeTime(p.Started), p.Command)
		}
	}

	t.Print()
}
開發者ID:gmelika,項目名稱:rack,代碼行數:14,代碼來源:ps.go

示例11: cmdRackReleases

func cmdRackReleases(c *cli.Context) {
	system, err := rackClient(c).GetSystem()

	if err != nil {
		stdcli.Error(err)
		return
	}

	pendingVersion := system.Version

	releases, err := rackClient(c).GetSystemReleases()

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("VERSION", "UPDATED", "STATUS")

	for i, r := range releases {
		status := ""

		if system.Status == "updating" && i == 0 {
			pendingVersion = r.Id
			status = "updating"
		}

		if system.Version == r.Id {
			status = "active"
		}

		t.AddRow(r.Id, humanizeTime(r.Created), status)
	}

	t.Print()

	next, err := version.Next(system.Version)

	if err != nil {
		return
	}

	if next > pendingVersion {
		// if strings.Compare(next, pendingVersion) == 1 {
		fmt.Println()
		fmt.Printf("New version available: %s\n", next)
	}
}
開發者ID:soulware,項目名稱:rack,代碼行數:48,代碼來源:rack.go

示例12: cmdRegistryList

func cmdRegistryList(c *cli.Context) {
	registries, err := rackClient(c).ListRegistries()

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("SERVER")

	for _, reg := range *registries {
		t.AddRow(reg.ServerAddress)
	}

	t.Print()
}
開發者ID:cleblanc87,項目名稱:rack,代碼行數:16,代碼來源:registries.go

示例13: cmdCertsList

func cmdCertsList(c *cli.Context) {
	certs, err := rackClient(c).ListCertificates()

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("ID", "DOMAIN", "EXPIRES")

	for _, cert := range certs {
		t.AddRow(cert.Id, cert.Domain, humanizeTime(cert.Expiration))
	}

	t.Print()
}
開發者ID:cleblanc87,項目名稱:rack,代碼行數:16,代碼來源:certs.go

示例14: cmdServices

func cmdServices(c *cli.Context) {
	services, err := rackClient(c).ListServices()

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("NAME", "TYPE", "STATUS")

	for _, service := range services {
		t.AddRow(service.Name, service.Type, service.Status)
	}

	t.Print()
}
開發者ID:harryross,項目名稱:rack,代碼行數:16,代碼來源:services.go

示例15: cmdApps

func cmdApps(c *cli.Context) {
	apps, err := rackClient(c).GetApps()

	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("APP", "STATUS")

	for _, app := range apps {
		t.AddRow(app.Name, app.Status)
	}

	t.Print()
}
開發者ID:harryross,項目名稱:rack,代碼行數:16,代碼來源:apps.go


注:本文中的github.com/convox/rack/cmd/convox/stdcli.NewTable函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。