Repository navigation
feat: add shell tab completion for bash, zsh, PowerShell and fish - #795
ZheFeng7110 wants to merge 2 commits into
Conversation
The fish adapter asked commandline for --tokens-expanded, a flag fish only gained in 4.0; the completion job's Ubuntu image ships fish 3.7, where the unknown flag left the word list empty and no candidate was produced. Ask for --tokenize (-o), which both lines accept and whose cut-at-cursor behaviour is the same. The Windows PowerShell job inherits MCPP from a Git Bash environment, so the value is /d/a/... rather than a native path and native Python resolved D:\d\a\... . Convert that spelling before resolving the binary.
|
可以尝试把这个命令补全功能在 cmdline 这个库里优化好, 这样后面直接升级版本即可使用 (mcpp / xlings 和其他使用 cmdline的库 ) , 目前 cmdline里有个初步的实现可以研究一下 核心是 各个平台适配 兼容性 通用性 和 不改变 cmdline api 通用模块 能让使用 cmdline 库的 程序天然自动带有 completion 功能 (可以很简单使用一个 app.xxx(true) 控制是否启用), 具体可以参考下面相关链接 |
|
好的。 cmdline 目前的补全功能经过分析还存在问题,我先去优化 cmdline。 |
|
我调查了 mcpplibs/cmdline#8 的做法,它的实现与本分支的方式不同: mcpplibs/cmdline#8 是 而本分支的实现原理是 对于 mcpp 这种子命令较复杂,并且需要动态补全(比如 所以如果要通过 cmdline 实现 mcpp 的补全功能,我认为需要修改 cmdline 的补全实现方式:可以把 mcpplibs/cmdline#8 的方案撤回,改成后者的方案(用户按下 tab -> |
可以把方案在 cmdline 创建一个 详细的补全方案设计 issue, 优先可以 看能不能基于已有的做优化 和 扩展,如果要重新设计 要做好 对比和场景支撑, 尽量的做的 小而美 和 易用性 |
Tab completion now follows mcpp's CLI definitions for commands, nested subcommands, long and short options, and built-in option values. Bash, zsh, PowerShell and fish adapters use a read-only candidate query and their native filename completion, including attached file arguments.
mcpp self completion [shell]writes scripts under<mcpp-home>/config/shell/without initializing a toolchain or accessing the network. Normal sandbox initialization also installs the scripts. The standalone installer adds a guarded loading command to the detected shell's profile, respects custom configuration directories and quoting, and avoids duplicate entries.MCPP_NO_COMPLETIONandMCPP_NO_PATHindependently disable profile changes, and pinned older releases remain installable. English and Chinese installation instructions document manual activation.Closes #794.
Validation:
mcpp build --jobs 1succeeds.MCPP_JOBS=1and the release profile: 150 test targets pass.CI requires all four shells on Linux and checks native PowerShell completion on Windows.