From 71f49bd24e290f9a1689a9a85e36cd2d14ba6f48 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Sat, 21 Nov 2026 04:42:47 +0900 Subject: [PATCH] mcpplibs.cmdline 0.0.5: snapshot(app) is exported The member moves to 0.0.5 and checks that snapshot names each subcommand and its options. GitHub and GitCode serve the same tag archive (sha256 a8fad985...). --- CHANGELOG.md | 2 ++ pkgs/c/cmdline.lua | 23 ++++++++++++++++++++++- tests/examples/cmdline/mcpp.toml | 2 +- tests/examples/cmdline/tests/consume.cpp | 6 ++++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7e6df96..2bb97541 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ ### Added +- **mcpplibs.cmdline 0.0.5.** `snapshot(const App&)` 是导出的函数,与 docs/api.md 所述一致:程序由解析它所用的定义列出自身的 + 命令与选项(mcpp 的 `mcpp emit surface`)。测试成员移到 0.0.5,并检验这一项。 - **mtest 0.11.0(mcpplibs.mtest、.manifest、.gtest、.capi)与新包 mcpplibs.mtest.doctest。** 协议的 `step` 与 `exercise` 事件(P5.6); 用例结束时检查它启动的进程与诊断行;机器的一份预算(O11)与抖动(O12);运行记录机器的类别;`[budget]` 与 `[ledger.*]` 由门禁判定;GCC 上一个文件的首个用例与期望由 689 ms 降为 265 ms。`mcpplibs.mtest.doctest` 是 doctest 的协议适配器(1 级), diff --git a/pkgs/c/cmdline.lua b/pkgs/c/cmdline.lua index 65a0019f..321046cf 100644 --- a/pkgs/c/cmdline.lua +++ b/pkgs/c/cmdline.lua @@ -2,7 +2,7 @@ -- 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 and 0.0.4 (0.0.3 adds src/completions*.cppm, which the glob takes in), +-- 0.0.2, 0.0.3, 0.0.4 and 0.0.5 (0.0.3 adds src/completions*.cppm, which the glob takes in), -- so a single Form B block describes every version correctly. -- When 0.0.1 is dropped, this can be replaced with `mcpp = "*/mcpp.toml"`. -- @@ -48,6 +48,13 @@ package = { }, sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a", }, + ["0.0.5"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz", + }, + sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf", + }, }, macosx = { ["0.0.1"] = { @@ -78,6 +85,13 @@ package = { }, sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a", }, + ["0.0.5"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz", + }, + sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf", + }, }, windows = { ["0.0.1"] = { @@ -108,6 +122,13 @@ package = { }, sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a", }, + ["0.0.5"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz", + }, + sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf", + }, }, }, diff --git a/tests/examples/cmdline/mcpp.toml b/tests/examples/cmdline/mcpp.toml index 7867f58b..9b33fa9a 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.3" +mcpplibs.cmdline = "0.0.5" diff --git a/tests/examples/cmdline/tests/consume.cpp b/tests/examples/cmdline/tests/consume.cpp index 942017b4..4b47ccd6 100644 --- a/tests/examples/cmdline/tests/consume.cpp +++ b/tests/examples/cmdline/tests/consume.cpp @@ -48,6 +48,12 @@ int main() { auto wrong = numbers.parse_from("tool --count 3px"); check(!wrong && wrong.error().is_error(), "a value that is not a number of the type is refused"); + // 0.0.5: the command tree is exported; a program lists its own commands and options from it. + auto tree = cmdline::snapshot(cmdline::App("tool").subcommand(cmdline::App("add").option(cmdline::Option("force")))); + check(tree.subcommands.size() == 1 && tree.subcommands[0].name == "add" + && !tree.subcommands[0].options.empty() && tree.subcommands[0].options[0].long_name == "force", + "snapshot names each subcommand and its options"); + if (failures == 0) std::println("cmdline: ok"); return failures == 0 ? 0 : 1; }