func (cmd *ListQuotas) Run(c *cli.Context) { cmd.ui.Say("Getting quotas as %s...", 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{"name", "memory limit", "routes", "service instances", "paid service plans"}) rows := [][]string{} for _, quota := range quotas { rows = append(rows, []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(rows) }
func (cmd *showQuota) Run(context *cli.Context) { quotaName := context.Args()[0] cmd.ui.Say("Getting quota %s info as %s...", quotaName, cmd.config.Username()) quota, err := cmd.quotaRepo.FindByName(quotaName) if err != nil { cmd.ui.Failed(err.Error()) } cmd.ui.Ok() table := terminal.NewTable(cmd.ui, []string{"", ""}) table.Print([][]string{ []string{"Memory", formatters.ByteSize(quota.MemoryLimit * formatters.MEGABYTE)}, []string{"Routes", fmt.Sprintf("%d", quota.RoutesLimit)}, []string{"Services", fmt.Sprintf("%d", quota.ServicesLimit)}, []string{"Paid service plans", formatters.Allowed(quota.NonBasicServicesAllowed)}, }) }