diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2017-05-23 11:06:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-23 11:06:25 -0400 |
commit | 5c1049054eace710abd3418bbad141fbb7dd5d7f (patch) | |
tree | 24d75c14ce2aae2c6f1a8d5bc7392e958e416666 /cmd/platform/user.go | |
parent | 69f3f2fdce4ae21a037ca61d753279efcc70f0ec (diff) | |
download | chat-5c1049054eace710abd3418bbad141fbb7dd5d7f.tar.gz chat-5c1049054eace710abd3418bbad141fbb7dd5d7f.tar.bz2 chat-5c1049054eace710abd3418bbad141fbb7dd5d7f.zip |
PLT-6471 Properly panic when translations can't be loaded (#6414)
* PLT-6471 Properly panic when translations can't be loaded
* Print usage messages when errors occur during CLI initialization
* Reverted behaviour of FindDir and added second return value to it
* Fixed merge conflict
Diffstat (limited to 'cmd/platform/user.go')
-rw-r--r-- | cmd/platform/user.go | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/cmd/platform/user.go b/cmd/platform/user.go index dc0aa0f71..74e71ebe3 100644 --- a/cmd/platform/user.go +++ b/cmd/platform/user.go @@ -157,7 +157,9 @@ func init() { } func userActivateCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } if len(args) < 1 { return errors.New("Enter user(s) to activate.") @@ -193,7 +195,9 @@ func changeUserActiveStatus(user *model.User, userArg string, activate bool) err } func userDeactivateCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } if len(args) < 1 { return errors.New("Enter user(s) to deactivate.") @@ -204,7 +208,10 @@ func userDeactivateCmdF(cmd *cobra.Command, args []string) error { } func userCreateCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + username, erru := cmd.Flags().GetString("username") if erru != nil || username == "" { return errors.New("Username is required") @@ -248,7 +255,10 @@ func userCreateCmdF(cmd *cobra.Command, args []string) error { } func userInviteCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + utils.InitHTML() if len(args) < 2 { @@ -285,7 +295,10 @@ func inviteUser(email string, team *model.Team, teamArg string) error { } func resetUserPasswordCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) != 2 { return errors.New("Incorect number of arguments.") } @@ -304,7 +317,10 @@ func resetUserPasswordCmdF(cmd *cobra.Command, args []string) error { } func resetUserMfaCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) < 1 { return errors.New("Enter at least one user.") } @@ -325,7 +341,10 @@ func resetUserMfaCmdF(cmd *cobra.Command, args []string) error { } func deleteUserCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) < 1 { return errors.New("Enter at least one user.") } @@ -362,7 +381,10 @@ func deleteUserCmdF(cmd *cobra.Command, args []string) error { } func deleteAllUsersCommandF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) > 0 { return errors.New("Don't enter any agruments.") } @@ -393,7 +415,10 @@ func deleteAllUsersCommandF(cmd *cobra.Command, args []string) error { } func migrateAuthCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) != 3 { return errors.New("Enter the correct number of arguments.") } @@ -431,7 +456,10 @@ func migrateAuthCmdF(cmd *cobra.Command, args []string) error { } func verifyUserCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) < 1 { return errors.New("Enter at least one user.") } @@ -452,7 +480,10 @@ func verifyUserCmdF(cmd *cobra.Command, args []string) error { } func searchUserCmdF(cmd *cobra.Command, args []string) error { - initDBCommandContextCobra(cmd) + if err := initDBCommandContextCobra(cmd); err != nil { + return err + } + if len(args) < 1 { return errors.New("Enter at least one query.") } |