增加 Zsh Tab 补全 - #395
Conversation
|
Hi @swim233, ❤️ 感谢你的贡献!你的 PR 当前基于 |
|
已切换pr分支 |
ccmywish
left a comment
There was a problem hiding this comment.
需要在 tool/completion/ 目录中增加一个 README,简要介绍 _describe compadd compset 的作用
| # `install` depends on the release binary by filename. Build it on demand | ||
| # when installing from a clean source tree; packaging flows that already ran | ||
| # build-in-release-mode can reuse the existing artifact. | ||
| $(ReleaseMode-Target-Name): |
There was a problem hiding this comment.
应该可以改成:
$(ReleaseMode-Target-Name): build-in-release-mode另外,注释需要改成中文
| clean-deb: | ||
| @$(MAKE) -C pkg/deb deb-clean | ||
|
|
||
| ZSH_COMPLETION_DIR ?= /usr/share/zsh/site-functions |
There was a problem hiding this comment.
CI的时候用的是另一个目录覆盖了这个变量,可以注释一下二者的区别
| # ----------------------------------------------------------------------------- | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
| # | ||
| # Check that the native Zsh completion contains every alias of every dish | ||
| # registered in src/recipe/menu.c. Internal sources-only dishes are not menu | ||
| # entries and therefore must not be offered to users. | ||
| # ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
文件标头要像 cli.pl 一样,有维护者信息,以及中文注释
There was a problem hiding this comment.
建议改名为 verify-sync-state-of-zsh-completion
|
|
||
| assert_has() { | ||
| local expected=$1 | ||
| if (( ! ${captured[(Ie)${expected}]} )); then |
| # ----------------------------------------------------------------------------- | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
| # | ||
| # Lightweight tests for the completion state machine. Completion widgets are | ||
| # mocked so the test does not touch the user's Zsh setup. | ||
| # ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
同其他文件,需要给一个文件标头,写明中文注释。
这个文件应该是自己用函数覆盖了Zsh 的行为,从而模拟 Zsh 的补全。建议更换文件名,清晰表达此含义。
2a167e4 to
e081399
Compare
我会尽量坚持维护,已经补充署名 文档稍后补充 |
新功能描述
目前 chsrc 仅提供 Bash 补全,Zsh 用户无法直接获得命令、选项、菜品和镜像参数的 Tab 补全。
本 PR 增加原生 Zsh 补全,并接入安装、Debian 打包、CI 与回归测试流程。
关联 issue:N/A
方案
_chsrc补全函数,不依赖bashcompinit。-scope=value与-scope valuelist的目标类型measure、get、set、reset的菜品参数set的镜像选择measure、mea、m、cesu等别名重复占据多行;用户手动输入别名后仍能继续补全。src/recipe/menu.c与 recipe 声明校验菜品别名,避免补全内容与实际注册菜单不同步。实现
Zsh 补全
新增
tool/completion/_chsrc,支持:help、issue、list、measure、get、set、reset、version-dry、-ipv6、-en、-no-color、-scope=default、project、user、system作用域first、upstream镜像选择补全状态会限制参数位置,例如菜品之后不再建议选项,
set已填写镜像后不再建议第二个镜像。安装与打包
make install将_chsrc安装到/usr/share/zsh/site-functions/usr/share/zsh/vendor-completionsmake install时缺少chsrc-release构建规则的问题测试与 CI
新增三类测试:
CI 会安装 Zsh,并通过
REQUIRE_ZSH=1确保相关测试不会被跳过。测试结果:
目前仅在arch中手动完成测试