MCPcopy
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/application/files.go:69–116  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

67}
68
69func (cmd *Files) Execute(c flags.FlagContext) error {
70 app := cmd.appReq.GetApplication()
71
72 var instance int
73 if c.IsSet("i") {
74 instance = c.Int("i")
75 if instance < 0 {
76 return errors.New(T("Invalid instance: {{.Instance}}\nInstance must be a positive integer",
77 map[string]interface{}{
78 "Instance": instance,
79 }))
80 }
81 if instance >= app.InstanceCount {
82 return errors.New(T("Invalid instance: {{.Instance}}\nInstance must be less than {{.InstanceCount}}",
83 map[string]interface{}{
84 "Instance": instance,
85 "InstanceCount": app.InstanceCount,
86 }))
87 }
88 }
89
90 cmd.ui.Say(T("Getting files for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
91 map[string]interface{}{
92 "AppName": terminal.EntityNameColor(app.Name),
93 "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
94 "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
95 "Username": terminal.EntityNameColor(cmd.config.Username())}))
96
97 path := "/"
98 if len(c.Args()) > 1 {
99 path = c.Args()[1]
100 }
101
102 list, err := cmd.appFilesRepo.ListFiles(app.GUID, instance, path)
103 if err != nil {
104 return err
105 }
106
107 cmd.ui.Ok()
108 cmd.ui.Say("")
109
110 if list == "" {
111 cmd.ui.Say("Empty file or folder")
112 } else {
113 cmd.ui.Say("%s", list)
114 }
115 return nil
116}

Callers

nothing calls this directly

Calls 11

EntityNameColorFunction · 0.92
GetApplicationMethod · 0.65
IsSetMethod · 0.65
IntMethod · 0.65
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
SpaceFieldsMethod · 0.65
UsernameMethod · 0.65
ArgsMethod · 0.65
ListFilesMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected