diff options
author | Jesús Espino <jespinog@gmail.com> | 2018-04-12 17:50:44 +0200 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-04-12 11:50:44 -0400 |
commit | 8df6d5cc30d22a608c58635449047e421add82ae (patch) | |
tree | fa1fba7c96cc9f41a35f46b9f092f51b7eff8e1b /cmd/commands/team.go | |
parent | 191e1ad5563aada1c282e43eb6fa043e317290c8 (diff) | |
download | chat-8df6d5cc30d22a608c58635449047e421add82ae.tar.gz chat-8df6d5cc30d22a608c58635449047e421add82ae.tar.bz2 chat-8df6d5cc30d22a608c58635449047e421add82ae.zip |
Add list command to teams command in CLI (#8612)
* Add list command to teams command in CLI
* Using App instead of Store to get the teams
Diffstat (limited to 'cmd/commands/team.go')
-rw-r--r-- | cmd/commands/team.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/commands/team.go b/cmd/commands/team.go index 9c07b7456..05de714d6 100644 --- a/cmd/commands/team.go +++ b/cmd/commands/team.go @@ -52,6 +52,14 @@ Permanently deletes a team along with all related information including posts fr RunE: deleteTeamsCmdF, } +var ListTeamsCmd = &cobra.Command{ + Use: "list", + Short: "List all teams.", + Long: `List all teams on the server.`, + Example: " team list", + RunE: listTeamsCmdF, +} + func init() { TeamCreateCmd.Flags().String("name", "", "Team Name") TeamCreateCmd.Flags().String("display_name", "", "Team Display Name") @@ -65,6 +73,7 @@ func init() { RemoveUsersCmd, AddUsersCmd, DeleteTeamsCmd, + ListTeamsCmd, ) cmd.RootCmd.AddCommand(TeamCmd) } @@ -216,3 +225,21 @@ func deleteTeamsCmdF(command *cobra.Command, args []string) error { func deleteTeam(a *app.App, team *model.Team) *model.AppError { return a.PermanentDeleteTeam(team) } + +func listTeamsCmdF(command *cobra.Command, args []string) error { + a, err := cmd.InitDBCommandContextCobra(command) + if err != nil { + return err + } + + teams, err2 := a.GetAllTeams() + if err2 != nil { + return err2 + } + + for _, team := range teams { + cmd.CommandPrettyPrintln(team.Name) + } + + return nil +} |