• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang stdcli.NewTable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/convox/rack/cmd/convox/stdcli.NewTable函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTable函数的具体用法?Golang NewTable怎么用?Golang NewTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewTable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: cmdRacks

func cmdRacks(c *cli.Context) {
	racks, err := rackClient(c).Racks()
	if err != nil {
		stdcli.Error(err)
		return
	}

	t := stdcli.NewTable("RACK", "STATUS")
	for _, rack := range racks {
		name := rack.Name
		if rack.Organization != nil {
			name = fmt.Sprintf("%s/%s", rack.Organization.Name, name)
		}
		t.AddRow(name, rack.Status)
	}
	t.Print()
}
开发者ID:cleblanc87,项目名称:rack,代码行数:17,代码来源:racks.go


示例17: cmdInstancesList

func cmdInstancesList(c *cli.Context) {
	instances, err := rackClient(c).GetInstances()

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

	t := stdcli.NewTable("ID", "IP", "STATUS", "PROCESSES", "CPU", "MEM")

	for _, i := range instances {
		t.AddRow(i.Id, i.Ip, i.Status, strconv.Itoa(i.Processes),
			fmt.Sprintf("%0.2f%%", i.Cpu*100),
			fmt.Sprintf("%0.2f%%", i.Memory*100))
	}
	t.Print()
}
开发者ID:gisnalbert,项目名称:rack,代码行数:17,代码来源:instances.go


示例18: TestTableOutput

func TestTableOutput(t *testing.T) {
	buf := &bytes.Buffer{}

	tb := stdcli.NewTable("FOO", "BAR")
	tb.Output = buf

	tb.AddRow("foo bar", "foo bar baz qux")
	tb.AddRow("bar foo baz", "foo")
	tb.Print()

	lines := strings.Split(buf.String(), "\n")

	assert.Equal(t, 4, len(lines))
	assert.Equal(t, "FOO          BAR", lines[0])
	assert.Equal(t, "foo bar      foo bar baz qux", lines[1])
	assert.Equal(t, "bar foo baz  foo", lines[2])
	assert.Equal(t, "", lines[3])
}
开发者ID:gmelika,项目名称:rack,代码行数:18,代码来源:table_test.go


示例19: cmdRacks

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

	racks, err := rackClient(c).Racks()
	if err != nil {
		return stdcli.Error(err)
	}

	t := stdcli.NewTable("RACK", "STATUS")
	for _, rack := range racks {
		name := rack.Name
		if rack.Organization != nil {
			name = fmt.Sprintf("%s/%s", rack.Organization.Name, name)
		}
		t.AddRow(name, rack.Status)
	}
	t.Print()
	return nil
}
开发者ID:convox,项目名称:rack,代码行数:21,代码来源:racks.go


示例20: cmdReleases

func cmdReleases(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 releases` does not take arguments. Perhaps you meant `convox registries info`?"))
	}

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

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

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

	t := stdcli.NewTable("ID", "CREATED", "BUILD", "STATUS")

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

		if a.Release == r.Id {
			status = "active"
		}

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

	t.Print()
	return nil
}
开发者ID:gmelika,项目名称:rack,代码行数:40,代码来源:releases.go



注:本文中的github.com/convox/rack/cmd/convox/stdcli.NewTable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang stdcli.RegisterCommand函数代码示例发布时间:2022-05-23
下一篇:
Golang stdcli.ExitError函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap