(c flags.FlagContext)
| 68 | } |
| 69 | |
| 70 | func (cmd *ListApps) Execute(c flags.FlagContext) error { |
| 71 | cmd.ui.Say(T("Getting apps in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", |
| 72 | map[string]interface{}{ |
| 73 | "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name), |
| 74 | "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name), |
| 75 | "Username": terminal.EntityNameColor(cmd.config.Username())})) |
| 76 | |
| 77 | apps, err := cmd.appSummaryRepo.GetSummariesInCurrentSpace() |
| 78 | |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | cmd.ui.Ok() |
| 84 | cmd.ui.Say("") |
| 85 | |
| 86 | if len(apps) == 0 { |
| 87 | cmd.ui.Say(T("No apps found")) |
| 88 | return nil |
| 89 | } |
| 90 | |
| 91 | table := cmd.ui.Table([]string{ |
| 92 | T("name"), |
| 93 | T("requested state"), |
| 94 | T("instances"), |
| 95 | T("memory"), |
| 96 | T("disk"), |
| 97 | T("urls"), |
| 98 | }) |
| 99 | |
| 100 | for _, application := range apps { |
| 101 | var urls []string |
| 102 | for _, route := range application.Routes { |
| 103 | urls = append(urls, route.URL()) |
| 104 | } |
| 105 | |
| 106 | table.Add( |
| 107 | application.Name, |
| 108 | uihelpers.ColoredAppState(application.ApplicationFields), |
| 109 | uihelpers.ColoredAppInstances(application.ApplicationFields), |
| 110 | formatters.ByteSize(application.Memory*formatters.MEGABYTE), |
| 111 | formatters.ByteSize(application.DiskQuota*formatters.MEGABYTE), |
| 112 | strings.Join(urls, ", "), |
| 113 | ) |
| 114 | } |
| 115 | |
| 116 | err = table.Print() |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | if cmd.pluginCall { |
| 121 | cmd.populatePluginModel(apps) |
| 122 | } |
| 123 | return nil |
| 124 | } |
| 125 | |
| 126 | func (cmd *ListApps) populatePluginModel(apps []models.Application) { |
| 127 | for _, app := range apps { |
nothing calls this directly
no test coverage detected