1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-09-15 18:56:59 +00:00

Fix incorrect CLI exit code and duplicate error message (#26346) (#26347)

Backport #26346

Follow the CLI refactoring, and add tests.
This commit is contained in:
wxiaoguang 2023-08-05 23:37:04 +08:00 committed by GitHub
parent 8a97cdd91b
commit fa431b377d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 104 additions and 4 deletions

View file

@ -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()
}