From fa431b377d7055c6c1362787eebda5b8b67e8d58 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 5 Aug 2023 23:37:04 +0800 Subject: Fix incorrect CLI exit code and duplicate error message (#26346) (#26347) Backport #26346 Follow the CLI refactoring, and add tests. --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 9b561376c3..8b48e8142e 100644 --- a/main.go +++ b/main.go @@ -146,11 +146,11 @@ func main() { app.Commands = append(app.Commands, subCmdWithIni...) app.Commands = append(app.Commands, subCmdStandalone...) - err := app.Run(os.Args) - if err != nil { - _, _ = fmt.Fprintf(app.Writer, "\nFailed to run with %s: %v\n", os.Args, err) + cli.OsExiter = func(code int) { + log.GetManager().Close() + os.Exit(code) } - + _ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp log.GetManager().Close() } -- cgit v1.2.3