gitea_hat/main.go

58 lines
1.3 KiB
Go
Raw Normal View History

2022-10-13 10:15:34 +08:00
package main
import (
"os"
"runtime"
"strings"
"time"
2023-11-22 10:21:57 +08:00
"code.gitea.io/gitea/modules/log"
2022-10-13 10:15:34 +08:00
"code.gitea.io/gitea/modules/setting"
2022-10-20 18:33:02 +08:00
hat_cmd "code.gitlink.org.cn/Gitlink/gitea_hat.git/cmd"
2023-11-22 10:21:57 +08:00
// register supported doc types
_ "code.gitea.io/gitea/modules/markup/asciicast"
_ "code.gitea.io/gitea/modules/markup/console"
_ "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"
2022-10-13 10:15:34 +08:00
)
var (
2023-11-22 10:21:57 +08:00
Version = "development"
Tags = ""
MakeVersion = ""
2022-10-13 10:15:34 +08:00
)
func init() {
setting.AppVer = Version
setting.AppBuiltWith = formatBuiltWith()
setting.AppStartTime = time.Now().UTC()
// Grab the original help templates
}
func main() {
2023-11-22 10:21:57 +08:00
cli.OsExiter = func(code int) {
log.GetManager().Close()
os.Exit(code)
2022-10-13 10:15:34 +08:00
}
2023-11-22 10:21:57 +08:00
app := hat_cmd.NewMainApp(Version, formatBuiltWith())
_ = hat_cmd.RunMainApp(app, os.Args...) // all errors should have been handled by the RunMainApp
log.GetManager().Close()
2022-10-13 10:15:34 +08:00
}
func formatBuiltWith() string {
version := runtime.Version()
if len(MakeVersion) > 0 {
version = MakeVersion + ", " + runtime.Version()
}
if len(Tags) == 0 {
return " built with " + version
}
return " built with " + version + " : " + strings.ReplaceAll(Tags, " ", ", ")
}