🐛 fix(tsl-syntax-reference): require exact long options in lookup cli

- drop the -h short option and disable long-option abbreviation: `--che`
  used to run `--check` and exit 0, so a misspelled argument silently
  performed a different action instead of failing
- document the lexicon/page alias validation under --check, now the only
  guard against a renamed page silently losing its natural language entry
- state that --query takes terms rather than the user's own words, and
  describe the weak-hit marker and its rc=2 in both --query help and epilog
This commit is contained in:
csh
2026-07-29 15:45:49 +08:00
parent 9ef45155dd
commit c6895fe41a
+17 -2
View File
@@ -1128,6 +1128,8 @@ HELP_EPILOG = """\
"02_core_model--文件模型核心规则"
查询词无从下手时先 --map 把需求映射到 TSL 概念;改动参考页或 data/ 词表后用 --check 校验。
弱命中(候选标 Weak: yes)没有意图/标题/标识符/标签命中,只靠正文低分撞词;
全部候选皆弱时视同无匹配并返回 rc=2,应改进查询词重试而不是从弱候选里挑。
"""
@@ -1136,12 +1138,24 @@ def _parser() -> argparse.ArgumentParser:
description="检索 TSL 语法参考页,取回可照写的语法事实。",
epilog=HELP_EPILOG,
formatter_class=argparse.RawDescriptionHelpFormatter,
# 只接受完整拼写的长选项:不提供 -h 短选项(add_help=False 后手工挂
# --help),也不接受缩写。缩写会让打错的参数静默命中另一个动作——
# `--che` 曾等同 `--check` 并以 rc=0 返回,看不出参数写错了。
add_help=False,
allow_abbrev=False,
)
parser.add_argument(
"--help",
action="help",
help="显示本帮助并退出(不提供 -h 短选项)",
)
action = parser.add_argument_group("动作(必选其一)").add_mutually_exclusive_group(
required=True
)
action.add_argument(
"--query", help="按用户原话、报错原文或语法要素名检索候选章节;需配合 --mode"
"--query",
help="按术语、报错原文或语法要素名检索候选章节(不要传用户原话);需配合 "
"--mode。候选标 `Weak: yes` 表示只有正文低分撞词,全部候选皆弱时退出码为 2",
)
action.add_argument(
"--section",
@@ -1159,7 +1173,8 @@ def _parser() -> argparse.ArgumentParser:
action.add_argument(
"--check",
action="store_true",
help="校验参考页的结构、代码块身份本地链接;发现问题时退出码为 1",
help="校验参考页的结构、代码块身份本地链接,以及 data/lexicon.json 的页级"
"意图短语与参考页是否一一对应;发现问题时退出码为 1",
)
parser.add_argument(
"--mode",