本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/terminal.NewTable函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTable函数的具体用法?Golang NewTable怎么用?Golang NewTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTable函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Run
func (cmd ShowSecurityGroup) Run(context *cli.Context) {
name := context.Args()[0]
cmd.ui.Say("Getting info for security group '%s' as '%s'", name, cmd.configRepo.Username())
securityGroup, err := cmd.securityGroupRepo.Read(name)
if err != nil {
cmd.ui.Failed(err.Error())
}
jsonEncodedBytes, encodingErr := json.MarshalIndent(securityGroup.Rules, "\t", "\t")
if encodingErr != nil {
cmd.ui.Failed(encodingErr.Error())
}
cmd.ui.Ok()
table := terminal.NewTable(cmd.ui, []string{"", ""})
table.Add("Name", securityGroup.Name)
table.Add("Rules", "")
table.Print()
cmd.ui.Say("\t" + string(jsonEncodedBytes))
cmd.ui.Say("")
if len(securityGroup.Spaces) > 0 {
table = terminal.NewTable(cmd.ui, []string{"", "Organization", "Space"})
for index, space := range securityGroup.Spaces {
table.Add(fmt.Sprintf("#%d", index), space.Organization.Name, space.Name)
}
table.Print()
} else {
cmd.ui.Say("No spaces assigned")
}
}
开发者ID:jbinfo,项目名称:cli,代码行数:35,代码来源:security_group.go
示例2: Execute
func (cmd *Plugins) Execute(c flags.FlagContext) {
var version string
cmd.ui.Say(T("Listing Installed Plugins..."))
plugins := cmd.config.Plugins()
var table terminal.Table
if c.Bool("checksum") {
cmd.ui.Say(T("Computing sha1 for installed plugins, this may take a while ..."))
table = terminal.NewTable(cmd.ui, []string{T("Plugin Name"), T("Version"), T("Command Name"), "sha1", T("Command Help")})
} else {
table = terminal.NewTable(cmd.ui, []string{T("Plugin Name"), T("Version"), T("Command Name"), T("Command Help")})
}
for pluginName, metadata := range plugins {
if metadata.Version.Major == 0 && metadata.Version.Minor == 0 && metadata.Version.Build == 0 {
version = "N/A"
} else {
version = fmt.Sprintf("%d.%d.%d", metadata.Version.Major, metadata.Version.Minor, metadata.Version.Build)
}
for _, command := range metadata.Commands {
args := []string{pluginName, version}
if command.Alias != "" {
args = append(args, command.Name+", "+command.Alias)
} else {
args = append(args, command.Name)
}
if c.Bool("checksum") {
checksum := utils.NewSha1Checksum(metadata.Location)
sha1, err := checksum.ComputeFileSha1()
if err != nil {
args = append(args, "n/a")
} else {
args = append(args, fmt.Sprintf("%x", sha1))
}
}
args = append(args, command.HelpText)
table.Add(args...)
}
}
cmd.ui.Ok()
cmd.ui.Say("")
table.Print()
}
开发者ID:vframbach,项目名称:cli,代码行数:51,代码来源:plugins.go
示例3: Run
func (cmd SecurityGroups) Run(context *cli.Context) {
cmd.ui.Say(T("Getting security groups as {{.username}}",
map[string]interface{}{
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
securityGroups, err := cmd.securityGroupRepo.FindAll()
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
cmd.ui.Say("")
if len(securityGroups) == 0 {
cmd.ui.Say(T("No security groups"))
return
}
table := terminal.NewTable(cmd.ui, []string{"", T("Name"), T("Organization"), T("Space")})
for index, securityGroup := range securityGroups {
if len(securityGroup.Spaces) > 0 {
cmd.printSpaces(table, securityGroup, index)
} else {
table.Add(fmt.Sprintf("#%d", index), securityGroup.Name, "", "")
}
}
table.Print()
}
开发者ID:jacopen,项目名称:cli,代码行数:30,代码来源:security_groups.go
示例4: Execute
func (cmd *ListApps) Execute(c flags.FlagContext) {
cmd.ui.Say(T("Getting apps in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
apps, apiErr := cmd.appSummaryRepo.GetSummariesInCurrentSpace()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
if len(apps) == 0 {
cmd.ui.Say(T("No apps found"))
return
}
table := terminal.NewTable(cmd.ui, []string{
T("name"),
T("requested state"),
T("instances"),
T("memory"),
T("disk"),
T("app ports"),
T("urls"),
})
for _, application := range apps {
var urls []string
for _, route := range application.Routes {
urls = append(urls, route.URL())
}
appPorts := make([]string, len(application.AppPorts))
for i, p := range application.AppPorts {
appPorts[i] = strconv.Itoa(p)
}
table.Add(
application.Name,
ui_helpers.ColoredAppState(application.ApplicationFields),
ui_helpers.ColoredAppInstances(application.ApplicationFields),
formatters.ByteSize(application.Memory*formatters.MEGABYTE),
formatters.ByteSize(application.DiskQuota*formatters.MEGABYTE),
strings.Join(appPorts, ", "),
strings.Join(urls, ", "),
)
}
table.Print()
if cmd.pluginCall {
cmd.populatePluginModel(apps)
}
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:60,代码来源:apps.go
示例5: Run
func (cmd ListStack) Run(c *cli.Context) {
stackName := c.Args()[0]
stack, apiErr := cmd.stacksRepo.FindByName(stackName)
if c.Bool("guid") {
cmd.ui.Say(stack.Guid)
} else {
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Say(T("Getting stack '{{.Stack}}' in org {{.OrganizationName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{"Stack": stackName,
"OrganizationName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{T("name"), T("description")})
table.Add(stack.Name, stack.Description)
table.Print()
}
}
开发者ID:tools-alexuser01,项目名称:cli,代码行数:27,代码来源:stack.go
示例6: Execute
func (cmd *ListFeatureFlags) Execute(c flags.FlagContext) {
cmd.ui.Say(T("Retrieving status of all flagged features as {{.Username}}...", map[string]interface{}{
"Username": terminal.EntityNameColor(cmd.config.Username())}))
flags, err := cmd.flagRepo.List()
if err != nil {
cmd.ui.Failed(err.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{T("Features"), T("State")})
for _, flag := range flags {
table.Add(
flag.Name,
cmd.flagBoolToString(flag.Enabled),
)
}
table.Print()
return
}
开发者ID:0976254669,项目名称:cli,代码行数:25,代码来源:feature_flags.go
示例7: Run
func (cmd ListStacks) Run(c *cli.Context) {
cmd.ui.Say("Getting stacks in org %s / space %s as %s...",
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
stacks, apiErr := cmd.stacksRepo.FindAll()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{"name", "description"})
for _, stack := range stacks {
table.Add([]string{
stack.Name,
stack.Description,
})
}
table.Print()
}
开发者ID:palakmathur,项目名称:cli,代码行数:27,代码来源:stacks.go
示例8: Execute
func (c *V3Apps) Execute(fc flags.FlagContext) {
applications, err := c.repository.GetApplications()
if err != nil {
c.ui.Failed(err.Error())
}
processes := make([][]models.V3Process, len(applications))
routes := make([][]models.V3Route, len(applications))
for i, app := range applications {
ps, err := c.repository.GetProcesses(app.Links.Processes.Href)
if err != nil {
c.ui.Failed(err.Error())
}
processes[i] = ps
rs, err := c.repository.GetRoutes(app.Links.Routes.Href)
if err != nil {
c.ui.Failed(err.Error())
}
routes[i] = rs
}
table := terminal.NewTable(c.ui, []string{T("name"), T("requested state"), T("instances"), T("memory"), T("disk"), T("urls")})
for i := range applications {
c.addRow(table, applications[i], processes[i], routes[i])
}
table.Print()
}
开发者ID:chavdarch,项目名称:cli,代码行数:31,代码来源:v3apps.go
示例9: Run
func (cmd *SpaceQuota) Run(c *cli.Context) {
name := c.Args()[0]
cmd.ui.Say(T("Getting space quota {{.Quota}} info as {{.Username}}...",
map[string]interface{}{
"Quota": terminal.EntityNameColor(name),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
spaceQuota, apiErr := cmd.spaceQuotaRepo.FindByName(name)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
var megabytes string
table := terminal.NewTable(cmd.ui, []string{"", ""})
table.Add(T("total memory limit"), formatters.ByteSize(spaceQuota.MemoryLimit*formatters.MEGABYTE))
if spaceQuota.InstanceMemoryLimit == -1 {
megabytes = "-1"
} else {
megabytes = formatters.ByteSize(spaceQuota.InstanceMemoryLimit * formatters.MEGABYTE)
}
table.Add(T("instance memory limit"), megabytes)
table.Add(T("routes"), fmt.Sprintf("%d", spaceQuota.RoutesLimit))
table.Add(T("services"), fmt.Sprintf("%d", spaceQuota.ServicesLimit))
table.Add(T("non basic services"), formatters.Allowed(spaceQuota.NonBasicServicesAllowed))
table.Print()
}
开发者ID:ramirito,项目名称:cli,代码行数:35,代码来源:space_quota.go
示例10: Run
func (cmd *ListQuotas) Run(c *cli.Context) {
cmd.ui.Say(T("Getting quotas as {{.Username}}...", map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())}))
quotas, apiErr := cmd.quotaRepo.FindAll()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{T("name"), T("memory limit"), T("routes"), T("service instances"), T("paid service plans")})
for _, quota := range quotas {
table.Add([]string{
quota.Name,
formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE),
fmt.Sprintf("%d", quota.RoutesLimit),
fmt.Sprintf("%d", quota.ServicesLimit),
formatters.Allowed(quota.NonBasicServicesAllowed),
})
}
table.Print()
}
开发者ID:GABONIA,项目名称:cli,代码行数:26,代码来源:quotas.go
示例11: Run
func (cmd *ServiceAccess) Run(c *cli.Context) {
brokerToFilter := c.String("b")
var brokers []models.ServiceBroker
var err error
if brokerToFilter != "" {
brokers, err = cmd.actor.GetBrokerWithDependencies(brokerToFilter)
} else {
brokers, err = cmd.actor.GetAllBrokersWithDependencies()
}
if err != nil {
cmd.ui.Failed(T("Failed fetching service brokers.\n%s"), err)
return
}
for _, serviceBroker := range brokers {
cmd.ui.Say(fmt.Sprintf(T("broker: %s"), serviceBroker.Name))
table := terminal.NewTable(cmd.ui, []string{"", T("service"), T("plan"), T("access"), T("orgs")})
for _, service := range serviceBroker.Services {
if len(service.Plans) > 0 {
for _, plan := range service.Plans {
table.Add("", service.Label, plan.Name, cmd.formatAccess(plan.Public, plan.OrgNames), strings.Join(plan.OrgNames, ","))
}
} else {
table.Add("", service.Label, "", "", "")
}
}
table.Print()
cmd.ui.Say("")
}
}
开发者ID:Kunsarka,项目名称:cli,代码行数:33,代码来源:service_access.go
示例12: Run
func (cmd ListStacks) Run(c *cli.Context) {
cmd.ui.Say(T("Getting stacks in org {{.OrganizationName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{"OrganizationName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
stacks, apiErr := cmd.stacksRepo.FindAll()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{T("name"), T("description")})
for _, stack := range stacks {
table.Add([]string{
stack.Name,
stack.Description,
})
}
table.Print()
}
开发者ID:GABONIA,项目名称:cli,代码行数:26,代码来源:stacks.go
示例13: Run
func (cmd *ServiceAccess) Run(c *cli.Context) {
brokers, err := cmd.actor.GetBrokersWithDependencies()
if err != nil {
cmd.ui.Failed("Failed fetching service brokers.\n%s", err)
return
}
for _, serviceBroker := range brokers {
cmd.ui.Say(fmt.Sprintf("broker: %s", serviceBroker.Name))
table := terminal.NewTable(cmd.ui, []string{"", "service", "plan", "access", "orgs"})
for _, service := range serviceBroker.Services {
if len(service.Plans) > 0 {
for _, plan := range service.Plans {
table.Add("", service.Label, plan.Name, cmd.formatAccess(plan.Public, plan.OrgNames), strings.Join(plan.OrgNames, ","))
}
} else {
table.Add("", service.Label, "", "", "")
}
}
table.Print()
cmd.ui.Say("")
}
}
开发者ID:jpalermo,项目名称:cli,代码行数:26,代码来源:service_access.go
示例14: WildcardCommandApps
func (cmd *Wildcard) WildcardCommandApps(cliConnection plugin.CliConnection, args []string) {
InitializeCliDependencies()
defer panic.HandlePanics()
cmd.getMatchedApps(cliConnection, args)
cmd.ui = terminal.NewUI(os.Stdin, terminal.NewTeePrinter())
table := terminal.NewTable(cmd.ui, []string{T("name"), T("requested state"), T("instances"), T("memory"), T("disk"), T("urls")})
for _, app := range cmd.matchedApps {
var urls []string
for _, route := range app.Routes {
if route.Host == "" {
urls = append(urls, route.Domain.Name)
}
urls = append(urls, fmt.Sprintf("%s.%s", route.Host, route.Domain.Name))
}
table.Add(
app.Name,
app.State,
strconv.Itoa(app.RunningInstances),
formatters.ByteSize(app.Memory*formatters.MEGABYTE),
formatters.ByteSize(app.DiskQuota*formatters.MEGABYTE),
strings.Join(urls, ", "),
)
}
table.Print()
}
开发者ID:guidowb,项目名称:Wildcard_Plugin,代码行数:25,代码来源:wildcard_plugin.go
示例15: Execute
func (cmd *showQuota) Execute(c flags.FlagContext) {
quotaName := c.Args()[0]
cmd.ui.Say(T("Getting quota {{.QuotaName}} info as {{.Username}}...", map[string]interface{}{"QuotaName": quotaName, "Username": cmd.config.Username()}))
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
var megabytes string
if quota.InstanceMemoryLimit == -1 {
megabytes = T("unlimited")
} else {
megabytes = formatters.ByteSize(quota.InstanceMemoryLimit * formatters.MEGABYTE)
}
servicesLimit := strconv.Itoa(quota.ServicesLimit)
if servicesLimit == "-1" {
servicesLimit = T("unlimited")
}
table := terminal.NewTable(cmd.ui, []string{"", ""})
table.Add(T("Total Memory"), formatters.ByteSize(quota.MemoryLimit*formatters.MEGABYTE))
table.Add(T("Instance Memory"), megabytes)
table.Add(T("Routes"), fmt.Sprintf("%d", quota.RoutesLimit))
table.Add(T("Services"), servicesLimit)
table.Add(T("Paid service plans"), formatters.Allowed(quota.NonBasicServicesAllowed))
table.Print()
}
开发者ID:vframbach,项目名称:cli,代码行数:30,代码来源:quota.go
示例16: Run
func (cmd MarketplaceServices) Run(c *cli.Context) {
var (
serviceOfferings models.ServiceOfferings
apiErr error
)
if cmd.config.HasSpace() {
cmd.ui.Say(T("Getting services from marketplace in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
serviceOfferings, apiErr = cmd.serviceRepo.GetServiceOfferingsForSpace(cmd.config.SpaceFields().Guid)
} else if !cmd.config.IsLoggedIn() {
cmd.ui.Say(T("Getting all services from marketplace..."))
serviceOfferings, apiErr = cmd.serviceRepo.GetAllServiceOfferings()
} else {
cmd.ui.Failed(T("Cannot list marketplace services without a targeted space"))
}
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
if len(serviceOfferings) == 0 {
cmd.ui.Say(T("No service offerings found"))
return
}
table := terminal.NewTable(cmd.ui, []string{T("service"), T("plans"), T("description")})
sort.Sort(serviceOfferings)
for _, offering := range serviceOfferings {
planNames := ""
for _, plan := range offering.Plans {
if plan.Name == "" {
continue
}
planNames = planNames + ", " + plan.Name
}
planNames = strings.TrimPrefix(planNames, ", ")
table.Add([]string{
offering.Label,
planNames,
offering.Description,
})
}
table.Print()
return
}
开发者ID:GABONIA,项目名称:cli,代码行数:59,代码来源:marketplace.go
示例17: Execute
func (cmd *ShowOrg) Execute(c flags.FlagContext) {
org := cmd.orgReq.GetOrganization()
if c.Bool("guid") {
cmd.ui.Say(org.Guid)
} else {
cmd.ui.Say(T("Getting info for org {{.OrgName}} as {{.Username}}...",
map[string]interface{}{
"OrgName": terminal.EntityNameColor(org.Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{terminal.EntityNameColor(org.Name) + ":", "", ""})
domains := []string{}
for _, domain := range org.Domains {
domains = append(domains, domain.Name)
}
spaces := []string{}
for _, space := range org.Spaces {
spaces = append(spaces, space.Name)
}
spaceQuotas := []string{}
for _, spaceQuota := range org.SpaceQuotas {
spaceQuotas = append(spaceQuotas, spaceQuota.Name)
}
quota := org.QuotaDefinition
appInstanceLimit := strconv.Itoa(quota.AppInstanceLimit)
if quota.AppInstanceLimit == resources.UnlimitedAppInstances {
appInstanceLimit = T("unlimited")
}
orgQuotaFields := []string{
T("{{.MemoryLimit}}M memory limit", map[string]interface{}{"MemoryLimit": quota.MemoryLimit}),
T("{{.InstanceMemoryLimit}} instance memory limit", map[string]interface{}{"InstanceMemoryLimit": formatters.InstanceMemoryLimit(quota.InstanceMemoryLimit)}),
T("{{.RoutesLimit}} routes", map[string]interface{}{"RoutesLimit": quota.RoutesLimit}),
T("{{.ServicesLimit}} services", map[string]interface{}{"ServicesLimit": quota.ServicesLimit}),
T("paid services {{.NonBasicServicesAllowed}}", map[string]interface{}{"NonBasicServicesAllowed": formatters.Allowed(quota.NonBasicServicesAllowed)}),
T("{{.AppInstanceLimit}} app instance limit", map[string]interface{}{"AppInstanceLimit": appInstanceLimit}),
}
orgQuota := fmt.Sprintf("%s (%s)", quota.Name, strings.Join(orgQuotaFields, ", "))
if cmd.pluginCall {
cmd.populatePluginModel(org, quota)
} else {
table.Add("", T("domains:"), terminal.EntityNameColor(strings.Join(domains, ", ")))
table.Add("", T("quota:"), terminal.EntityNameColor(orgQuota))
table.Add("", T("spaces:"), terminal.EntityNameColor(strings.Join(spaces, ", ")))
table.Add("", T("space quotas:"), terminal.EntityNameColor(strings.Join(spaceQuotas, ", ")))
table.Print()
}
}
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:59,代码来源:org.go
示例18: Run
func (cmd ShowSecurityGroup) Run(context *cli.Context) {
name := context.Args()[0]
cmd.ui.Say(T("Getting info for security group {{.security_group}} as {{.username}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(name),
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
securityGroup, err := cmd.securityGroupRepo.Read(name)
if err != nil {
cmd.ui.Failed(err.Error())
}
jsonEncodedBytes, encodingErr := json.MarshalIndent(securityGroup.Rules, "\t", "\t")
if encodingErr != nil {
cmd.ui.Failed(encodingErr.Error())
}
cmd.ui.Ok()
table := terminal.NewTable(cmd.ui, []string{"", ""})
table.Add(T("Name"), securityGroup.Name)
table.Add(T("Rules"), "")
table.Print()
cmd.ui.Say("\t" + string(jsonEncodedBytes))
cmd.ui.Say("")
if len(securityGroup.Spaces) > 0 {
table = terminal.NewTable(cmd.ui, []string{"", T("Organization"), T("Space")})
for index, space := range securityGroup.Spaces {
table.Add(fmt.Sprintf("#%d", index), space.Organization.Name, space.Name)
}
table.Print()
} else {
cmd.ui.Say(T("No spaces assigned"))
}
}
开发者ID:BlueSpice,项目名称:cli,代码行数:39,代码来源:security_group.go
示例19: Execute
func (cmd *ListSpaceQuotas) Execute(c flags.FlagContext) {
cmd.ui.Say(T("Getting space quotas as {{.Username}}...", map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())}))
quotas, apiErr := cmd.spaceQuotaRepo.FindByOrg(cmd.config.OrganizationFields().Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := terminal.NewTable(cmd.ui, []string{
T("name"),
T("total memory limit"),
T("instance memory limit"),
T("routes"),
T("service instances"),
T("paid service plans"),
T("app instance limit"),
})
var megabytes string
for _, quota := range quotas {
if quota.InstanceMemoryLimit == -1 {
megabytes = T("unlimited")
} else {
megabytes = formatters.ByteSize(quota.InstanceMemoryLimit * formatters.MEGABYTE)
}
servicesLimit := strconv.Itoa(quota.ServicesLimit)
if servicesLimit == "-1" {
servicesLimit = T("unlimited")
}
table.Add(
quota.Name,
formatters.ByteSize(quota.MemoryLimit*formatters.MEGABYTE),
megabytes,
fmt.Sprintf("%d", quota.RoutesLimit),
fmt.Sprintf(servicesLimit),
formatters.Allowed(quota.NonBasicServicesAllowed),
T(quota.FormattedAppInstanceLimit()),
)
}
table.Print()
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:50,代码来源:space_quotas.go
示例20: Run
func (cmd ListApps) Run(c *cli.Context) {
cmd.ui.Say("Getting apps in org %s / space %s as %s...",
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apps, apiErr := cmd.appSummaryRepo.GetSummariesInCurrentSpace()
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say("")
if len(apps) == 0 {
cmd.ui.Say("No apps found")
return
}
table := terminal.NewTable(cmd.ui, []string{
"name",
"requested state",
"instances",
"memory",
"disk",
"urls",
})
for _, application := range apps {
var urls []string
for _, route := range application.Routes {
urls = append(urls, route.URL())
}
table.Add([]string{
application.Name,
ui_helpers.ColoredAppState(application.ApplicationFields),
ui_helpers.ColoredAppInstances(application.ApplicationFields),
formatters.ByteSize(application.Memory * formatters.MEGABYTE),
formatters.ByteSize(application.DiskQuota * formatters.MEGABYTE),
strings.Join(urls, ", "),
})
}
table.Print()
}
开发者ID:palakmathur,项目名称:cli,代码行数:49,代码来源:apps.go
注:本文中的github.com/cloudfoundry/cli/cf/terminal.NewTable函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论