package kos import ( "git.nobla.cn/golang/kos/entry/cli" "git.nobla.cn/golang/kos/entry/http" _ "git.nobla.cn/golang/kos/pkg/request" _ "git.nobla.cn/golang/kos/util/arrays" _ "git.nobla.cn/golang/kos/util/bs" _ "git.nobla.cn/golang/kos/util/fetch" _ "git.nobla.cn/golang/kos/util/humanize" _ "git.nobla.cn/golang/kos/util/random" _ "git.nobla.cn/golang/kos/util/reflection" _ "git.nobla.cn/golang/kos/util/sys" "sync" ) var ( once sync.Once app Application ) func initialization(cbs ...Option) { once.Do(func() { app = New(cbs...) }) } func Init(cbs ...Option) Application { initialization(cbs...) return app } func Name() string { initialization() return app.Info().Name } func ShortName() string { initialization() if entry, ok := app.(*application); ok { return entry.opts.ShortName() } return app.Info().Name } func Version() string { initialization() return app.Info().Version } func Debug(args ...any) bool { initialization() if entry, ok := app.(*application); ok { if len(args) <= 0 { return entry.opts.EnableDebug } if b, ok := args[0].(bool); ok { entry.opts.EnableDebug = b } return entry.opts.EnableDebug } return false } func Node() *Info { initialization() return app.Info() } func Http() *http.Server { initialization() return app.Http() } func Command() *cli.Server { initialization() return app.Command() } func Handle(method string, cb HandleFunc) { initialization() app.Handle(method, cb) }