From 43b1a1d5640932c3e9a7295b508071798be94c02 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Thu, 3 Dec 2026 06:54:11 +0900 Subject: [PATCH] mcpplibs.cmdline 0.0.7: subcommands in groups and in one order for help, snapshot and messages; a help epilogue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `pkgs/c/cmdline.lua`: 0.0.7 on linux, macosx and windows; GitHub and GitCode serve the same tag archive (sha256 2e998d70…); the Form B source glob covers the layout. - `tests/examples/cmdline` moves to 0.0.7 and checks the grouped, by-name listing without the hidden command. - CHANGELOG. --- CHANGELOG.md | 4 ++++ pkgs/c/cmdline.lua | 25 ++++++++++++++++++++++-- tests/examples/cmdline/mcpp.toml | 2 +- tests/examples/cmdline/tests/consume.cpp | 13 ++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 426775a4..89347b56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ ### Added +- **mcpplibs.cmdline 0.0.7.** 帮助把子命令分组、按名排序,并在列表之后给出结语:`app.group(s)` 声明子命令所在的组, + `app.help_options({ .order = alphabetical, .ungrouped = "..." })` 让组内与其余命令按名排列并给其余命令一个标题,`app.help_epilogue(s)` + 在子命令之后打印。`print_help`、`snapshot(app)` 与“缺少子命令”的提示读同一份列表,程序的帮助、补全与提示一致;什么都不声明时 + 帮助与 0.0.6 逐字节相同,解析不变。CN 镜像是 mcpp-res/cmdline 的 0.0.7 release 资产(与 GitHub 归档同一字节,sha256 2e998d70…)。 - **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)。 - **mcpplibs.cmdline 0.0.6.** 命令补全内建:`app.completion()` 一次调用开启,程序以自己的命令树回答(`__complete`),bash、zsh、 fish、PowerShell 的适配脚本只向程序询问;选项与参数可陈述可选值、文件或目录提示与候选回调,命令可隐藏。测试成员移到 0.0.6, diff --git a/pkgs/c/cmdline.lua b/pkgs/c/cmdline.lua index 5c306e46..d5a601c1 100644 --- a/pkgs/c/cmdline.lua +++ b/pkgs/c/cmdline.lua @@ -2,8 +2,8 @@ -- 0.0.2+ ships an upstream `mcpp.toml`, but `mcpp` is a package-level field -- (not per-version) in xpkg.lua, so to keep 0.0.1 installable we keep the -- workaround table here. The src/**/*.cppm layout is the same across 0.0.1, --- 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; --- 0.0.6 replaces src/completions/ with src/complete.cppm), +-- 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; +-- 0.0.6 replaces src/completions/ with src/complete.cppm; 0.0.7 changes src/cmdline.cppm only), -- so a single Form B block describes every version correctly. -- When 0.0.1 is dropped, this can be replaced with `mcpp = "*/mcpp.toml"`. -- @@ -63,6 +63,13 @@ package = { }, sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5", }, + ["0.0.7"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz", + }, + sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49", + }, }, macosx = { ["0.0.1"] = { @@ -107,6 +114,13 @@ package = { }, sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5", }, + ["0.0.7"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz", + }, + sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49", + }, }, windows = { ["0.0.1"] = { @@ -151,6 +165,13 @@ package = { }, sha256 = "24716d498f29544c56bff1015ecf8e2c06a0ae40443ee0d9edaeb8f770d8bdb5", }, + ["0.0.7"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.7.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.7/cmdline-0.0.7.tar.gz", + }, + sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49", + }, }, }, diff --git a/tests/examples/cmdline/mcpp.toml b/tests/examples/cmdline/mcpp.toml index d32bd0a8..10390347 100644 --- a/tests/examples/cmdline/mcpp.toml +++ b/tests/examples/cmdline/mcpp.toml @@ -10,4 +10,4 @@ name = "cmdline-tests" version = "0.1.0" [dependencies] -mcpplibs.cmdline = "0.0.6" +mcpplibs.cmdline = "0.0.7" diff --git a/tests/examples/cmdline/tests/consume.cpp b/tests/examples/cmdline/tests/consume.cpp index 0c4d0553..205d24c0 100644 --- a/tests/examples/cmdline/tests/consume.cpp +++ b/tests/examples/cmdline/tests/consume.cpp @@ -61,6 +61,19 @@ int main() { "completion offers the values an option states"); check(!completing.parse_from("tool --color pink"), "a value outside the stated set is refused"); + // 0.0.7: a help lists its subcommands in groups and by name, and the snapshot reads that same listing. + auto grouped = cmdline::App("tool") + .help_options({ .order = cmdline::HelpOrder::alphabetical, .ungrouped = "other" }) + .subcommand(cmdline::App("tag").group("work")) + .subcommand(cmdline::App("pr").group("work")) + .subcommand(cmdline::App("config")) + .subcommand(cmdline::App("auth")) + .subcommand(cmdline::App("secret").hidden()); + std::vector listed; + for (const auto& c : cmdline::snapshot(grouped).subcommands) listed.push_back(c.name); + check(listed == std::vector{"pr", "tag", "auth", "config"}, + "the listing groups its subcommands, by name inside each, without the hidden one"); + if (failures == 0) std::println("cmdline: ok"); return failures == 0 ? 0 : 1; }