[MM-65830] Fix mmctl system status exit code for health check failures (#33970) (#34069)

Automatic Merge
Этот коммит содержится в:
Mattermost Build
2025-10-06 14:43:38 +03:00
коммит произвёл GitHub
родитель 9dd2c6f54f
Коммит 4b56488fcb
3 изменённых файлов: 144 добавлений и 6 удалений

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

@@ -65,7 +65,14 @@ func Run(args []string) error {
}
}()
return RootCmd.Execute()
err := RootCmd.Execute()
// Flush the printer first before printing any error
_ = printer.Flush()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
}
return err
}
func printPanic(x any) {
@@ -114,8 +121,6 @@ var RootCmd = &cobra.Command{
printer.PrintError(fmt.Sprintf("Per page value is greater than the maximum allowed. Mattermost might only return %d items.", MaxPageSize))
}
},
PersistentPostRun: func(cmd *cobra.Command, args []string) {
_ = printer.Flush()
},
SilenceUsage: true,
SilenceUsage: true,
SilenceErrors: true,
}