Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AppCheckCmd = &gcli.Command{ Name: "check", Desc: "check the kite app runtime env information", Func: func(c *gcli.Command, args []string) error { baseDir := app.App().BaseDir confDir := app.App().ConfigDir dotenvFile := fsutil.JoinPaths(baseDir, appconst.DotEnvFileName) infos := []struct { title string answer string }{ { "Kite base data dir: " + baseDir, fmt.Sprintf("Exists: %v", fsutil.IsDir(baseDir)), }, { "Kite dotenv file: " + dotenvFile, fmt.Sprintf("Exists: %v", fsutil.IsFile(dotenvFile)), }, { "Kite config directory: " + confDir, fmt.Sprintf("Exists: %v", fsutil.IsDir(confDir)), }, } for _, info := range infos { c.Println("-", info.title) c.Infoln(">", info.answer) } return nil }, }
AppCheckCmd command
View Source
var BackendServeCmd = &gcli.Command{ Name: "serve", Aliases: []string{"be-serve", "server"}, Desc: "kite backend serve application", Func: func(c *gcli.Command, args []string) error { return errorx.New("todo") }, }
BackendServeCmd kite backend background server
View Source
var CommandMapCmd = &gcli.Command{ Name: "cmd-map", Aliases: []string{"cmdmap"}, Desc: "display all console commands info for kite", Config: func(c *gcli.Command) { c.BoolOpt2(&cmOpts.withFlag, "flags, flag", "output with command options and arguments") c.VarOpt(&cmOpts.format, "format", "f", "can be custom the output format") c.StrOpt2(&cmOpts.output, "output, o", "custom output, default is stdout", gflag.WithDefault("stdout")) }, Func: func(c *gcli.Command, args []string) error { if cmOpts.format.String() == "json" { } return errorx.New("todo") }, }
CommandMapCmd command
View Source
var KiteAliasCmd = &gcli.Command{ Name: "alias", Aliases: []string{"aliases", "cmd-alias"}, Desc: "show custom command aliases in app(config:aliases)", Config: func(c *gcli.Command) { goutil.MustOK(c.UseSimpleRule().FromStruct(kaOpts)) c.AddArg("name", "get real-name of the input alias").WithAfterFn(func(a *gflag.CliArg) error { kaOpts.Name = a.String() return nil }) }, Func: func(c *gcli.Command, _ []string) error { if kaOpts.List { show.AList("Command aliases", cmdbiz.Kas) return nil } if kaOpts.Name != "" { fmt.Println(cmdbiz.Kas.ResolveAlias(kaOpts.Name)) return nil } return errorx.New("please input alias for get command") }, }
KiteAliasCmd command
View Source
var KiteConfCmd = &gcli.Command{ Name: "config", Aliases: []string{"conf", "cfg"}, Desc: "display kite config information", Config: func(c *gcli.Command) { c.BoolOpt2(&confOpts.all, "all,a", "display all config data") c.BoolOpt2(&confOpts.keys, "keys", "display raw config data") c.StrOpt2(&confOpts.search, "search,s", "search top key by input keywords") c.AddArg("key", "show config for the input key") }, Func: func(c *gcli.Command, args []string) error { if confOpts.keys { names := make([]string, 16) for name := range app.Cfg().Data() { names = append(names, name) } c.Infoln("All Config Keys:") dump.Clear(names) return nil } if confOpts.all { c.Infoln("All Config Data:") dump.Clear(app.Cfg().Data()) return nil } key := c.Arg("key").String() if key == "" { return errorx.Raw("please input key for show configuration") } switch key { case "git": key = app.ObjGit case "glab": key = app.ObjGlab case "hub", "ghub": key = app.ObjGhub } data, ok := app.Cfg().GetValue(key) if !ok { return c.NewErrf("not found config for key: %s", key) } c.Infoln("Config for key:", key) dump.Clear(data) return nil }, }
KiteConfCmd command
View Source
var KiteInfoCmd = &gcli.Command{ Name: "info", Desc: "show the kite tool information", Func: func(c *gcli.Command, args []string) error { show.AList("information", map[string]any{ "user home dir": sysutil.UserHomeDir(), "app bin dir": c.Ctx.BinDir(), "app bin file": c.Ctx.BinFile(), "user data dir": app.App().BaseDir, "work dir": c.Ctx.WorkDir(), "dotenv file": app.App().DotenvFile(), "config files": app.Cfg().LoadedFiles(), "language": "TODO", "version": kite.Version, "build date": kite.BuildDate, "go version": kite.GoVersion, "github repo": kite.GithubRepo, }, nil) return nil }, }
KiteInfoCmd instance
View Source
var KiteInitCmd = &gcli.Command{ Name: "init", Desc: "init kite .env, config to the user home dir", Config: func(c *gcli.Command) { c.BoolOpt2(&ikOpts.dryRun, "dry-run, dry", "run workflow, dont real execute") c.BoolOpt2(&ikOpts.force, "force, f", "force re-init kite app config") }, Func: func(c *gcli.Command, args []string) error { c.Warnln("Pre-check:") uHome := sysutil.UserHomeDir() c.Infoln("Found user home dir:", uHome) baseDir := app.App().BaseDir dotenvFile := fsutil.JoinPaths(baseDir, appconst.DotEnvFileName) confFile := fsutil.JoinPaths(baseDir, appconst.KiteConfigName) c.Infoln("Will init kite .env and config and more...") if ikOpts.dryRun { c.Warnln("TIP: on DRY-RUN mode, will not be execute any operation") } qr := goutil.NewQuickRun() qr.Add(func(ctx *structs.Data) error { idx := ctx.IntVal("index") + 1 c.Infof("%d. Make the kite base dir: %s\n", idx, baseDir) if ikOpts.dryRun { return nil } if !ikOpts.force && fsutil.IsFile(baseDir) { c.Warnln(" Exists, skip write!") return nil } return fsutil.Mkdir(baseDir, fsutil.DefaultDirPerm) }, func(ctx *structs.Data) error { idx := ctx.IntVal("index") + 1 c.Infof("%d. Init the .env file: %s\n", idx, dotenvFile) if ikOpts.dryRun { return nil } if !ikOpts.force && fsutil.IsFile(dotenvFile) { c.Warnln(" Exists, skip write!") return nil } text := byteutil.SafeString(kite.EmbedFs.ReadFile(".example.env")) _, err := fsutil.PutContents(dotenvFile, text, fsutil.FsCWTFlags) return err }, func(ctx *structs.Data) error { idx := ctx.IntVal("index") + 1 c.Infof("%d. Init the main config file: %s\n", idx, confFile) if ikOpts.dryRun { return nil } if !ikOpts.force && fsutil.IsFile(confFile) { c.Warnln(" Exists, skip write!") return nil } text := byteutil.SafeString(kite.EmbedFs.ReadFile("kite.example.yml")) _, err := fsutil.PutContents(confFile, text, fsutil.FsCWTFlags) return err }, func(ctx *structs.Data) error { subDirs := []string{"config", "data", "scripts", "plugins", "tmp"} idx := ctx.IntVal("index") + 1 c.Infof("%d. Init subdir in %s: %v\n", idx, baseDir, subDirs) if ikOpts.dryRun { return nil } return fsutil.MkSubDirs(fsutil.DefaultDirPerm, baseDir, subDirs...) }, func(ctx *structs.Data) error { idx := ctx.IntVal("index") + 1 c.Infof("%d. Init kite config files to %s/config\n", idx, baseDir) if ikOpts.dryRun { return nil } return exportEmbedDir(kite.EmbedFs, "config", baseDir+"/config", true) }) cliutil.Warnln("\nStarting init:") err := qr.Run() if err == nil { cliutil.Successln("✅ Init Completed") } return err }, }
KiteInitCmd command
View Source
var KiteObjectCmd = &gcli.Command{ Name: "object", Aliases: []string{"obj"}, Desc: "display service object config struct on kite", Config: func(c *gcli.Command) { c.AddArg("name", "show info for the object") }, Func: func(c *gcli.Command, args []string) error { var data any key := c.Arg("name").String() switch key { case "app", "kite": data = app.App().Config case "git", "gitx": data = app.Gitx() case "glab", "gitlab": data = app.Glab() default: if app.Has(key) { data = app.GetAny(key) } } if data == nil { return c.NewErrf("not found object for %q", key) } c.Warnln("Object info for", key) dump.Clear(data) return nil }, }
KiteObjectCmd command
View Source
var KitePathCmd = &gcli.Command{ Name: "path", Aliases: []string{"paths"}, Desc: "show the kite system path information", Config: func(c *gcli.Command) { c.BoolOpt2(&kpOpts.list, "list, all, a, l", "display all paths for the kite") c.AddArg("path", "special alias path for resolve. prefix: base, config, tmp") }, Func: func(c *gcli.Command, args []string) error { if kpOpts.list { show.AList("Kite paths", app.App().Config) return nil } path := c.Arg("path").String() if path == "" { return errorx.Raw("please input path for resolve") } path = app.App().ResolvePath(path) if path == "" { return errorx.Rawf("not found path for %q", path) } fmt.Println(path) return nil }, }
KitePathCmd command
View Source
var LogWriteCmd = &gcli.Command{ Name: "logw", Aliases: []string{"log"}, Desc: "write a log message to the kite app logs file", Config: func(c *gcli.Command) { c.MustFromStruct(&lwOpts, gflag.TagRuleSimple) c.AddArg("message", "the log message", true) }, Func: func(c *gcli.Command, _ []string) error { app.L.Log(slog.LevelByName(lwOpts.Level), c.Arg("message").String()) return nil }, }
LogWriteCmd instance
View Source
var ManageCmd = &gcli.Command{ Name: "app", Aliases: []string{"self"}, Desc: "provide commands for manage kite self", Subs: []*gcli.Command{ AppCheckCmd, KiteInitCmd, KiteInfoCmd, KiteObjectCmd, UpdateSelfCmd, KiteConfCmd, ReadmeCmd, KitePathCmd, NewPathMapCmd(), KiteAliasCmd, BackendServeCmd, CommandMapCmd, LogWriteCmd, }, }
ManageCmd manage kite self
View Source
var ReadmeCmd = &gcli.Command{ Name: "readme", Aliases: []string{"doc", "docs"}, Desc: "show readme docs for kite app", Config: func(c *gcli.Command) { }, Func: func(c *gcli.Command, _ []string) error { str := byteutil.SafeString(kite.EmbedFs.ReadFile("README.md")) return apputil.RenderContents(str, "markdown", "github") }, }
ReadmeCmd instance
View Source
var UpdateSelfCmd = &gcli.Command{ Name: "update", Aliases: []string{"update-self", "up-self", "up"}, Desc: "update {$binName} to latest from github repository", }
UpdateSelfCmd command
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.