diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-05 23:36:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-05 23:36:45 +0800 |
commit | d92b4cd0935fcb7be3fb30253426988aada78d32 (patch) | |
tree | cf09184e89a46fc4ee8b1b8901da5f4712dba162 /main.go | |
parent | 4f513474dce9788bead4799fefe2ed2fdfa75213 (diff) | |
download | gitea-d92b4cd0935fcb7be3fb30253426988aada78d32.tar.gz gitea-d92b4cd0935fcb7be3fb30253426988aada78d32.zip |
Fix incorrect CLI exit code and duplicate error message (#26346)
Follow the CLI refactoring, and add tests.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -5,7 +5,6 @@ package main import ( - "fmt" "os" "runtime" "strings" @@ -21,6 +20,8 @@ import ( _ "code.gitea.io/gitea/modules/markup/csv" _ "code.gitea.io/gitea/modules/markup/markdown" _ "code.gitea.io/gitea/modules/markup/orgmode" + + "github.com/urfave/cli/v2" ) // these flags will be set by the build flags @@ -37,17 +38,12 @@ func init() { } func main() { - app := cmd.NewMainApp() - app.Name = "Gitea" - app.Usage = "A painless self-hosted Git service" - app.Description = `By default, Gitea will start serving using the web-server with no argument, which can alternatively be run by running the subcommand "web".` - app.Version = Version + formatBuiltWith() - - 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) } - + app := cmd.NewMainApp(Version, formatBuiltWith()) + _ = cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp log.GetManager().Close() } |