func getFromEmail(app, email string) (api.Collaborator, error) { collaborators, err := api.CollaboratorsList(app) if err != nil { return api.Collaborator{}, errgo.Mask(err, errgo.Any) } for _, collaborator := range collaborators { if collaborator.Email == email { return collaborator, nil } } return api.Collaborator{}, notFound }
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 }
func List(app string) error { collaborators, err := api.CollaboratorsList(app) if err != nil { return errgo.Mask(err, errgo.Any) } t := tablewriter.NewWriter(os.Stdout) t.SetHeader([]string{"Email", "Username", "Status"}) for _, collaborator := range collaborators { t.Append([]string{collaborator.Email, collaborator.Username, collaborator.Status}) } t.Render() return nil }
func CollaboratorsRemoveAutoComplete(c *cli.Context) error { appName := CurrentAppCompletion(c) if appName == "" { return nil } collaborators, err := api.CollaboratorsList(appName) if err == nil { for _, col := range collaborators { fmt.Println(col.Email) } } return nil }