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
Этот коммит содержится в:
Harrison Healey
2017-05-23 11:06:25 -04:00
коммит произвёл GitHub
родитель 69f3f2fdce
Коммит 5c1049054e
23 изменённых файлов: 189 добавлений и 73 удалений

Просмотреть файл

@@ -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.")
}