MCPcopy Index your code
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/application/apps.go:70–124  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

68}
69
70func (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
126func (cmd *ListApps) populatePluginModel(apps []models.Application) {
127 for _, app := range apps {

Callers

nothing calls this directly

Calls 15

populatePluginModelMethod · 0.95
EntityNameColorFunction · 0.92
ColoredAppStateFunction · 0.92
ColoredAppInstancesFunction · 0.92
ByteSizeFunction · 0.92
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
SpaceFieldsMethod · 0.65
UsernameMethod · 0.65
OkMethod · 0.65
TableMethod · 0.65

Tested by

no test coverage detected