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+versionExtra
app.EnableBashCompletion=true
// these sub-commands need to use config file
@ -166,3 +171,18 @@ func NewMainApp() *cli.App {
returnapp
}
funcRunMainApp(app*cli.App,args...string)error{
err:=app.Run(args)
iferr==nil{
returnnil
}
ifstrings.HasPrefix(err.Error(),"flag provided but not defined:"){
// the cli package should already have output the error message, so just exit
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)
iferr!=nil{
_,_=fmt.Fprintf(app.Writer,"\nFailed to run with %s: %v\n",os.Args,err)
cli.OsExiter=func(codeint){
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