Documentation ¶
Index ¶
Constants ¶
View Source
const ( ScopeAll = iota ScopeNamed ScopeHistory )
Variables ¶
View Source
var AutoJumpChdirCmd = &gcli.Command{ Name: "chdir", Aliases: []string{"into", "to"}, Desc: "add directory path to history, by the jump dir hooks.", Config: func(c *gcli.Command) { c.MustFromStruct(&ajcOpts, gflag.TagRuleSimple) c.AddArg("path", "The real directory path. if empty, use current workdir") }, Func: func(c *gcli.Command, _ []string) error { path := c.Arg("path").String() if len(path) == 0 { return c.NewErrf("path is empty or invalid") } realPath, ok := app.QJump.AddHistory(path) if ok { app.L.Infof("jump to path %q success", realPath) if !ajcOpts.Quiet { colorp.Successf("Into %q\n", realPath) } } else { colorp.Warnf("Invalid path %q\n", realPath) } return nil }, }
AutoJumpChdirCmd command
View Source
var AutoJumpGetCmd = &gcli.Command{ Name: "get", Aliases: []string{"path"}, Desc: "Get the real directory path by given name.", Config: func(c *gcli.Command) { c.MustFromStruct(&ajgOpts, gflag.TagRuleSimple) c.AddArg("keywords", "The target directory name or path or keywords.\n Start with ^ for exclude", true, true) }, Func: func(c *gcli.Command, _ []string) error { keywords := c.Arg("keywords").Strings() dirPath := app.QJump.CheckOrMatch(keywords) if !ajgOpts.Quiet && len(dirPath) == 0 { return c.NewErrf("not found path by keywords: %v", keywords) } app.L.Infof("input keywords: %v, match dirPath: %s", keywords, dirPath) stdio.WriteString(dirPath) return nil }, }
AutoJumpGetCmd command
View Source
var AutoJumpListCmd = &gcli.Command{ Name: "list", Aliases: []string{"ls"}, Desc: "list the jump storage data in local", Config: func(c *gcli.Command) { c.AddArg("type", "the jump info type name. allow: prev,last,history,all") }, Func: func(c *gcli.Command, _ []string) error { colorp.Infof("Jump storage datafile: %s\n", app.QJump.Datafile()) colorp.Greenln("Jump storage data in local:") dp := dump.NewWithOptions(dump.WithoutPosition(), dump.SkipPrivate()) dp.Println(app.QJump.Metadata) show.MList(app.QJump.Metadata) return nil }, }
AutoJumpListCmd command
View Source
var AutoJumpMatchCmd = &gcli.Command{ Name: "search", Aliases: []string{"hint", "match"}, Desc: "Match directory paths by given keywords", Config: func(c *gcli.Command) { c.MustFromStruct(&ajmOpts, gflag.TagRuleSimple) c.AddArg("keywords", "The keywords to match, allow limit by multi", false, true) }, Func: func(c *gcli.Command, _ []string) error { var results []string keywords := c.Arg("keywords").Strings() keywords = app.QJump.FormatKeywords(keywords) if ajmOpts.Scope == ScopeNamed { results = app.QJump.SearchNamed(keywords, ajmOpts.Limit, !ajmOpts.OnlyPath) } else if ajmOpts.Scope == ScopeHistory { results = app.QJump.SearchHistory(keywords, ajmOpts.Limit) } else { results = app.QJump.Search(keywords, ajmOpts.Limit, !ajmOpts.OnlyPath) } var sb strings.Builder matchNum := len(results) app.L.Infof("input search keywords %v, search results: %v", keywords, results) for i, dirPath := range results { sb.WriteString(dirPath) if matchNum != i+1 { sb.WriteByte('\n') } } stdio.WriteString(sb.String()) return nil }, }
AutoJumpMatchCmd command
View Source
var AutoJumpSetCmd = &gcli.Command{ Name: "set", Aliases: []string{"add"}, Desc: "Set the name to real directory path mapping", Config: func(c *gcli.Command) { c.AddArg("name", "The name of the directory path", true) c.AddArg("path", "The real directory path", true) }, Func: func(c *gcli.Command, _ []string) error { name := c.Arg("name").String() path := c.Arg("path").String() if app.QJump.AddNamed(name, path) { colorp.Successf("Set jump name %q to path %q\n", name, path) } else { colorp.Warnln("Set jump name %q to path %q failed", name, path) } return nil }, }
AutoJumpSetCmd command
View Source
var AutoJumpShellCmd = &gcli.Command{ Name: "shell", Aliases: []string{"active", "script"}, Desc: "Generate shell script for give shell env name.", Help: ` Enable quick jump for bash(add to <mga>~/.bashrc</>): # shell func is: jump <mga>eval "$(kite tool jump shell bash)"</> Enable quick jump for zsh(add to <mga>~/.zshrc</>): # shell func is: jump <mga>eval "$(kite tool jump shell zsh)"</> # set the bind func name is: j <mga>eval "$(kite tool jump shell --bind j zsh)"</> `, Config: func(c *gcli.Command) { c.MustFromStruct(&jsOpts, gflag.TagRuleSimple) c.AddArg("shell", "The shell name. eg: bash, zsh, fish, etc.") }, Func: func(c *gcli.Command, _ []string) error { shellName := c.Arg("shell").String() if shellName == "" { shellName = sysutil.CurrentShell(true) } if !quickjump.IsSupported(shellName) { colorp.Redf("The shell %q is not supported yet!\n", shellName) return nil } script, err := quickjump.GenScript(shellName, jsOpts.Bind) if err != nil { return err } stdio.WriteString(script) return nil }, }
AutoJumpShellCmd command
View Source
var DateCmd = &gcli.Command{ Name: "date", Aliases: []string{"dt", "time"}, Desc: "display or parse the date and time", Subs: []*gcli.Command{ DatePrintCmd, }, }
DateCmd command
View Source
var DatePrintCmd = &gcli.Command{ Name: "print", Desc: "print the current date and time", Config: func(c *gcli.Command) { c.MustFromStruct(&dateParseOpts) }, Func: func(c *gcli.Command, _ []string) error { tx := timex.Now() s := tx.DateFormat(dateParseOpts.Format) if dateParseOpts.Inline { fmt.Print(s) } else { fmt.Println(s) } return nil }, }
DatePrintCmd command
View Source
var MathCalcCmd = &gcli.Command{ Name: "math", Aliases: []string{"calc"}, Desc: "list the jump storage data in local", Config: func(c *gcli.Command) { }, Func: func(c *gcli.Command, _ []string) error { return errorx.New("TODO") }, }
MathCalcCmd command
View Source
var QuickJumpCleanCmd = &gcli.Command{ Name: "clean", Aliases: []string{"clear"}, Desc: "clean invalid directory paths from history", Config: func(c *gcli.Command) { c.AddArg("path", "The history directory path. if empty, clean all invalid dirs") }, Func: func(c *gcli.Command, args []string) error { ss := app.QJump.CleanHistories() if len(ss) > 0 { show.AList("Cleaned invalid paths", ss) } else { colorp.Infoln("No invalid paths to clean") } return nil }, }
QuickJumpCleanCmd command
View Source
var QuickJumpCmd = &gcli.Command{ Name: "jump", Aliases: []string{"goto"}, Desc: "Jump helps you navigate faster by your history.", Subs: []*gcli.Command{ AutoJumpListCmd, AutoJumpShellCmd, AutoJumpMatchCmd, AutoJumpGetCmd, AutoJumpSetCmd, AutoJumpChdirCmd, QuickJumpCleanCmd, }, Config: func(c *gcli.Command) { }, }
QuickJumpCmd command
View Source
var RunAnyCmd = &gcli.Command{ Name: "run", Desc: "Run any aliases and scripts, as well as plug-ins and system commands", Aliases: []string{"exec"}, Config: func(c *gcli.Command) { runOpts.BindCommonFlags(c) runOpts.wrapType.SetEnum(kscript.AllowTypes) c.BoolOpt2(&runOpts.listAll, "list, l", "List information for all scripts or one script") c.BoolOpt2(&runOpts.showInfo, "show, info, i", "Show information for input alias/script/plugin name") c.BoolOpt2(&runOpts.search, "search, s", "Display all matched scripts by the input name") c.BoolOpt2(&runOpts.verbose, "verbose, v", "Display context information on execute") c.BoolOpt2(&runOpts.plugin, "plugin", "dont check and direct run alias command on kite") c.BoolOpt2(&runOpts.alias, "alias", "dont check and direct run alias command on kite") c.BoolOpt2(&runOpts.script, "script", "dont check and direct run user script on kite") c.BoolOpt2(&runOpts.system, "system, sys", "dont check and direct run command on system") c.StrOpt2(&runOpts.chdir, "chdir, cd", "auto find match dir and chdir as workdir") c.VarOpt2(&runOpts.envMap, "env,e", "custom set ENV value on run command, format: `KEY=VALUE`") c.VarOpt(&runOpts.wrapType, "type", "", "wrap shell type for run input script, allow: "+runOpts.wrapType.EnumString()) c.AddArg("command", "The command for execute, can be with custom arguments") }, Func: runAnything, Help: ` ## System command $ kite run ls -al ## Custom scripts > default in the scripts.yml or dir: $base/scripts Can use '$@' '$*' at script line. will auto replace to input arguments examples: # scripts.yml st: git status co: git checkout $@ br: git branch $* `, }
RunAnyCmd instance
View Source
var ShellCmd = &gcli.Command{ Name: "shell", Aliases: []string{"sh"}, Desc: "Listen, record, query user executed shell command", Subs: []*gcli.Command{ ShellListenCmd, }, Config: func(c *gcli.Command) { }, }
ShellCmd os shell tool command
View Source
var ShellListenCmd = &gcli.Command{ Name: "listen", Aliases: []string{"watch"}, Desc: "Listen user executed shell command", Config: func(c *gcli.Command) { }, Func: func(c *gcli.Command, args []string) error { return nil }, }
ShellListenCmd listen user executed command
View Source
var ToolsCmd = &gcli.Command{ Name: "tool", Aliases: []string{"tools"}, Desc: "provide some useful help tools commands", Subs: []*gcli.Command{ swagcmd.SwaggerCmd, syscmd.NewBatchRunCmd(), syscmd.NewEnvInfoCmd(), appcmd.NewPathMapCmd(), fscmd.NewFileCatCmd(), DateCmd, QuickJumpCmd, convcmd.ConvBaseCmd, MathCalcCmd, TranslateCmd, convcmd.NewTime2dateCmd(), convcmd.NewDate2tsCmd(), convcmd.NewConvPathSepCmd(), syscmd.NewClipboardCmd(), pkgcmd.PkgManageCmd, doccmd.DocumentCmd, doccmd.NewCheatCmd(), mdcmd.MkDownCmd, syscmd.NewQuickOpenCmd(), extcmd.TaskManageCmd, textcmd.NewMd5Cmd(), textcmd.NewHashCmd(), textcmd.NewUuidCmd(), }, Config: func(c *gcli.Command) { }, }
ToolsCmd command
View Source
var TranslateCmd = &gcli.Command{ Name: "translate", Aliases: []string{"trans", "tr", "fy"}, Desc: "translate the input contents to the target language", Config: func(c *gcli.Command) { }, Func: func(c *gcli.Command, _ []string) error { return errorx.New("TODO") }, }
TranslateCmd command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.