本文整理汇总了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()
}
}
示例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()
}
示例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()
}
示例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
}
示例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()
}
示例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
}
示例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
}
示例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()
}
示例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()
}
示例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()
}
示例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)
}
}
示例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()
}
示例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()
}
示例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()
}
示例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()
}