func (c *AppLister) Run(cliConnection plugin.CliConnection, args []string) { orgs, err := cliConnection.GetOrgs() if err != nil { fmt.Println("Error getting orgs:", err) os.Exit(1) } for _, org := range orgs { _, err := cliConnection.CliCommandWithoutTerminalOutput("t", "-o", org.Name) if err != nil { fmt.Println("Error targeting org: ", org.Name) os.Exit(1) } apps, err := cliConnection.GetApps() if err != nil { fmt.Println("Error getting applications from org: ", org.Name) os.Exit(1) } for _, app := range apps { fmt.Println(app.Name) } } }
func (cmd *Wildcard) getMatchedApps(cliConnection plugin.CliConnection, args []string) []plugin_models.ApplicationSummary { pattern := args[1] output, _ := cliConnection.GetApps() for i := 0; i < (len(output)); i++ { ok, _ := filepath.Match(pattern, output[i].Name) if ok { cmd.matchedApps = append(cmd.matchedApps, output[i]) } } return cmd.matchedApps }
func GetAppsInOneOrg(cliConnection plugin.CliConnection, orgName string) ([]plugin_models.GetAppsModel, error) { _, err := cliConnection.CliCommandWithoutTerminalOutput("target", "-o", orgName) if err != nil { return []plugin_models.GetAppsModel{}, errors.New("Failed to target org '" + orgName + "'") } apps, err := cliConnection.GetApps() if err != nil { return []plugin_models.GetAppsModel{}, errors.New("Failed to get apps in organization '" + orgName + "'") } return apps, nil }
func getMatchedApps(cliConnection plugin.CliConnection, args string) []plugin_models.GetAppsModel { pattern := args output, err := cliConnection.GetApps() checkError(err) matchedApps := []plugin_models.GetAppsModel{} for i := 0; i < len(output); i++ { ok, _ := filepath.Match(pattern, output[i].Name) if ok { matchedApps = append(matchedApps, output[i]) } } return matchedApps }
// AppsStateStopped will return a list of app whose state is running func (c *DoctorPlugin) AppsStateStopped(cliConnection plugin.CliConnection) []plugin_models.GetAppsModel { var res []plugin_models.GetAppsModel appsListing, err := cliConnection.GetApps() if err != nil { c.ui.Failed(err.Error()) } for _, app := range appsListing { if app.State == "stopped" { res = append(res, app) } } return res }