func List() error { apps, err := api.AppsList() if err != nil { return errgo.Mask(err, errgo.Any) } if len(apps) == 0 { fmt.Println(io.Indent("\nYou haven't created any app yet, create your first application using:\n→ scalingo create <app_name>\n", 2)) return nil } t := tablewriter.NewWriter(os.Stdout) t.SetHeader([]string{"Name", "Role", "Owner"}) for _, app := range apps { if app.Owner.Email == api.CurrentUser.Email { t.Append([]string{app.Name, "owner", "-"}) } else { t.Append([]string{app.Name, "collaborator", fmt.Sprintf("%s <%s>", app.Owner.Username, app.Owner.Email)}) } } t.Render() return nil }
func FlagAppAutoComplete(c *cli.Context) bool { apps, err := api.AppsList() if err != nil || len(apps) == 0 { return false } for _, app := range apps { fmt.Println(app.Name) } return true }
func CollaboratorsAddAutoComplete(c *cli.Context) error { appName := CurrentAppCompletion(c) if appName == "" { return nil } apps, err := api.AppsList() if err != nil { return nil } currentAppCollaborators, err := api.CollaboratorsList(appName) if err != nil { return nil } setEmails := make(map[string]bool) for _, app := range apps { appCollaborators, err := api.CollaboratorsList(app.Name) if err != nil { return nil } for _, col := range appCollaborators { setEmails[col.Email] = true } } for email, _ := range setEmails { isAlreadyCollaborator := false for _, currentAppCol := range currentAppCollaborators { if currentAppCol.Email == email { isAlreadyCollaborator = true } } if !isAlreadyCollaborator { fmt.Println(email) } } return nil }