Skip to content

Commit bcf6e27

Browse files
authored
mcpplibs.cmdline 0.0.7: subcommands in groups and in one order for help, snapshot and messages; a help epilogue (#974)
mcpplibs.cmdline 0.0.7 (mcpplibs/cmdline#15): a help can list its subcommands in groups and by name, and say what comes after the list. One listing serves `print_help`, `snapshot(app)` and the message that a subcommand is required. Nothing opted in, the help is byte-identical to 0.0.6.
1 parent 35a2a6d commit bcf6e27

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
### Added
1111

12+
- **mcpplibs.cmdline 0.0.7.** 帮助把子命令分组、按名排序,并在列表之后给出结语:`app.group(s)` 声明子命令所在的组,
13+
`app.help_options({ .order = alphabetical, .ungrouped = "..." })` 让组内与其余命令按名排列并给其余命令一个标题,`app.help_epilogue(s)`
14+
在子命令之后打印。`print_help`、`snapshot(app)` 与“缺少子命令”的提示读同一份列表,程序的帮助、补全与提示一致;什么都不声明时
15+
帮助与 0.0.6 逐字节相同,解析不变。CN 镜像是 mcpp-res/cmdline 的 0.0.7 release 资产(与 GitHub 归档同一字节,sha256 2e998d70…)。
1216
- **compat.harfbuzz 14.3.0 的两个开关:`no-unused-api` 与 `no-aat-vertical`(修订 3)。** 与 `no-freetype` 同一种写法:mcpp 给本包的单元定义 `MCPP_FEATURE_NO_UNUSED_API`、`MCPP_FEATURE_NO_AAT_VERTICAL`,生成的 `config.h` 据此定义 HarfBuzz 自己的 `HB_NO_*`。`no-unused-api` 去掉只画字的程序不会调用的 API(缓冲区的序列化、校验与消息,MATH 与 meta 表,整形器不用的布局 API,字形名,样式查询),整形与绘制不变;`no-aat-vertical` 再去掉 Apple 的 AAT 整形(morx、kerx、trak)与竖排,给字体带 OpenType 布局、只横排的程序。默认都关,构建与以前相同。实测(emsdk 6.0.9,`-Oz`,只链接一个整形器调用的 57 个 `hb_*` 函数的程序):wasm 556,891 → 531,727 B(gzip 218,946 → 208,442),两个都开 461,992 B(gzip 187,747)。
1317
- **mcpplibs.cmdline 0.0.6.** 命令补全内建:`app.completion()` 一次调用开启,程序以自己的命令树回答(`__complete`),bash、zsh、
1418
fish、PowerShell 的适配脚本只向程序询问;选项与参数可陈述可选值、文件或目录提示与候选回调,命令可隐藏。测试成员移到 0.0.6,

‎pkgs/c/cmdline.lua‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- 0.0.2+ ships an upstream `mcpp.toml`, but `mcpp` is a package-level field
33
-- (not per-version) in xpkg.lua, so to keep 0.0.1 installable we keep the
44
-- workaround table here. The src/**/*.cppm layout is the same across 0.0.1,
5-
-- 0.0.2, 0.0.3, 0.0.4, 0.0.5 and 0.0.6 (0.0.3 adds src/completions*.cppm, which the glob takes in;
6-
-- 0.0.6 replaces src/completions/ with src/complete.cppm),
5+
-- 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6 and 0.0.7 (0.0.3 adds src/completions*.cppm, which the glob takes in;
6+
-- 0.0.6 replaces src/completions/ with src/complete.cppm; 0.0.7 changes src/cmdline.cppm only),
77
-- so a single Form B block describes every version correctly.
88
-- When 0.0.1 is dropped, this can be replaced with `mcpp = "*/mcpp.toml"`.
99
--
@@ -63,6 +63,13 @@ package = {
6363
},
6464
sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5",
6565
},
66+
["0.0.7"] = {
67+
url = {
68+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz",
69+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz",
70+
},
71+
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
72+
},
6673
},
6774
macosx = {
6875
["0.0.1"] = {
@@ -107,6 +114,13 @@ package = {
107114
},
108115
sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5",
109116
},
117+
["0.0.7"] = {
118+
url = {
119+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz",
120+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz",
121+
},
122+
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
123+
},
110124
},
111125
windows = {
112126
["0.0.1"] = {
@@ -151,6 +165,13 @@ package = {
151165
},
152166
sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5",
153167
},
168+
["0.0.7"] = {
169+
url = {
170+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz",
171+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz",
172+
},
173+
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
174+
},
154175
},
155176
},
156177

‎tests/examples/cmdline/mcpp.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ name = "cmdline-tests"
1010
version = "0.1.0"
1111

1212
[dependencies]
13-
mcpplibs.cmdline = "0.0.6"
13+
mcpplibs.cmdline = "0.0.7"

‎tests/examples/cmdline/tests/consume.cpp‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ int main() {
6161
"completion offers the values an option states");
6262
check(!completing.parse_from("tool --color pink"), "a value outside the stated set is refused");
6363

64+
// 0.0.7: a help lists its subcommands in groups and by name, and the snapshot reads that same listing.
65+
auto grouped = cmdline::App("tool")
66+
.help_options({ .order = cmdline::HelpOrder::alphabetical, .ungrouped = "other" })
67+
.subcommand(cmdline::App("tag").group("work"))
68+
.subcommand(cmdline::App("pr").group("work"))
69+
.subcommand(cmdline::App("config"))
70+
.subcommand(cmdline::App("auth"))
71+
.subcommand(cmdline::App("secret").hidden());
72+
std::vector<std::string> listed;
73+
for (const auto& c : cmdline::snapshot(grouped).subcommands) listed.push_back(c.name);
74+
check(listed == std::vector<std::string>{"pr", "tag", "auth", "config"},
75+
"the listing groups its subcommands, by name inside each, without the hidden one");
76+
6477
if (failures == 0) std::println("cmdline: ok");
6578
return failures == 0 ? 0 : 1;
6679
}

0 commit comments

Comments
 (0)