summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/commands/channel.go4
-rw-r--r--cmd/commands/config_flag_test.go2
-rw-r--r--cmd/commands/message_export_test.go2
-rw-r--r--cmd/commands/team.go27
-rw-r--r--cmd/commands/team_test.go18
5 files changed, 49 insertions, 4 deletions
diff --git a/cmd/commands/channel.go b/cmd/commands/channel.go
index 597a22450..d7b48f04c 100644
--- a/cmd/commands/channel.go
+++ b/cmd/commands/channel.go
@@ -31,7 +31,7 @@ var RemoveChannelUsersCmd = &cobra.Command{
Use: "remove [channel] [users]",
Short: "Remove users from channel",
Long: "Remove some users from channel",
- Example: " channel remove mychannel user@example.com username",
+ Example: " channel remove myteam:mychannel user@example.com username",
RunE: removeChannelUsersCmdF,
}
@@ -39,7 +39,7 @@ var AddChannelUsersCmd = &cobra.Command{
Use: "add [channel] [users]",
Short: "Add users to channel",
Long: "Add some users to channel",
- Example: " channel add mychannel user@example.com username",
+ Example: " channel add myteam:mychannel user@example.com username",
RunE: addChannelUsersCmdF,
}
diff --git a/cmd/commands/config_flag_test.go b/cmd/commands/config_flag_test.go
index 7ea0d5153..f31c989d8 100644
--- a/cmd/commands/config_flag_test.go
+++ b/cmd/commands/config_flag_test.go
@@ -22,7 +22,7 @@ func TestConfigFlag(t *testing.T) {
defer os.RemoveAll(dir)
utils.TranslationsPreInit()
- config, _, err := utils.LoadConfig("config.json")
+ config, _, _, err := utils.LoadConfig("config.json")
require.Nil(t, err)
configPath := filepath.Join(dir, "foo.json")
require.NoError(t, ioutil.WriteFile(configPath, []byte(config.ToJson()), 0600))
diff --git a/cmd/commands/message_export_test.go b/cmd/commands/message_export_test.go
index 5170b77af..bd0e049d6 100644
--- a/cmd/commands/message_export_test.go
+++ b/cmd/commands/message_export_test.go
@@ -57,7 +57,7 @@ func writeTempConfig(t *testing.T, isMessageExportEnabled bool) string {
require.NoError(t, err)
utils.TranslationsPreInit()
- config, _, appErr := utils.LoadConfig("config.json")
+ config, _, _, appErr := utils.LoadConfig("config.json")
require.Nil(t, appErr)
config.MessageExportSettings.EnableExport = model.NewBool(isMessageExportEnabled)
configPath := filepath.Join(dir, "foo.json")
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
+}
diff --git a/cmd/commands/team_test.go b/cmd/commands/team_test.go
index 1a91df4bc..ac006dbe1 100644
--- a/cmd/commands/team_test.go
+++ b/cmd/commands/team_test.go
@@ -4,6 +4,7 @@
package commands
import (
+ "strings"
"testing"
"github.com/mattermost/mattermost-server/api"
@@ -78,3 +79,20 @@ func TestLeaveTeam(t *testing.T) {
}
}
}
+
+func TestListTeams(t *testing.T) {
+ th := api.Setup().InitBasic()
+ defer th.TearDown()
+
+ id := model.NewId()
+ name := "name" + id
+ displayName := "Name " + id
+
+ cmd.CheckCommand(t, "team", "create", "--name", name, "--display_name", displayName)
+
+ output := cmd.CheckCommand(t, "team", "list", th.BasicTeam.Name, th.BasicUser.Email)
+
+ if !strings.Contains(string(output), name) {
+ t.Fatal("should have the created team")
+ }
+}