From 5c1049054eace710abd3418bbad141fbb7dd5d7f Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Tue, 23 May 2017 11:06:25 -0400 Subject: 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 --- cmd/platform/user.go | 53 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) (limited to 'cmd/platform/user.go') 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.") } -- cgit v1.2.3-1-g7c22