✨ feat(vscode): 命令规则加装软件包、装依赖、跑程序(apt-get、apk、pip、npm、pnpm、yarn、corepack、uv、uvicorn)和建用户、密钥、装文件、改属主(useradd、adduser、addgroup、gpg、install、chown);选项写到 4 个以上或写了几遍时排成「选项 | 意思」表;没有自己规则的命令交给管 * 的规则(只问 --version 的读成打印版本);curl -sS 只写不打印进度,source 读成读入里面的变量和函数

This commit is contained in:
cruldra committed 2026-09-28 11:53:54 +08:00
1 parent 149cb51cc0
commit 0665f35821
7 files changed
+764 -37

No files matched your search

+5 -2
View File
@@ -16,7 +16,10 @@ function guarded(rule: CommandRule, report: (message: string) => void): CommandR
}
}
/** 命令名 → 命令规则(SourceDocument.commandRule):几条规则都管同一个名字时先注册的算。 */
/** 管没有自己的规则的命令的规则写的命令名。 */
const ANY_COMMAND = '*'
/** 命令名 → 命令规则(SourceDocument.commandRule):几条规则都管同一个名字时先注册的算;没有自己的规则的交给管 '*' 的。 */
export function commandRuleLookup(rules: readonly CommandRule[], report: (message: string) => void): (name: string) => CommandRule | undefined {
const byName = new Map<string, CommandRule>()
for (const rule of rules) {
@@ -26,5 +29,5 @@ export function commandRuleLookup(rules: readonly CommandRule[], report: (messag
byName.set(name, safe)
}
}
return name => byName.get(name)
return name => byName.get(name) ?? byName.get(ANY_COMMAND)
}