From b11c6e5a33b8cf305034edfcb7be514fac36306e Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 9 Nov 2026 16:00:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?mcpplibs.cmdline=200.0.3:=20value=5Ftype?= =?UTF-8?q?()=20=E2=80=94=20numeric=20options=20checked=20by=20the=20parse?= =?UTF-8?q?;=20value=5Fas()=20reads=20them=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ pkgs/c/cmdline.lua | 26 ++++++++++++++++++++++-- tests/examples/cmdline/mcpp.toml | 2 +- tests/examples/cmdline/tests/consume.cpp | 7 +++++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0bcc82c..00f02db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ ### Added +- **mcpplibs.cmdline 0.0.3.** `value_type()` 声明选项取 `T` 类型的数字,解析时用 `std::from_chars` 校验,不合法即解析错误; + `value_as()` 读回。测试成员移到 0.0.3,并检验这两项。 - **mtest 0.5.2.** 四个包的 0.5.2:自启动副本的测试以对象 `child` 声明副本所做之事、以 `child_command` 启动之, 故不再定义 `main`,同一目录的文件可为一个程序;库对 mcpplibs.os 的要求为 `^0.4.1`。测试成员移到 0.5.2。 - **mtest 0.5.1.** 四个包的 0.5.1:协议标记在只保留可达部分的链接(`--gc-sections`)中保留,`mcpp test` diff --git a/pkgs/c/cmdline.lua b/pkgs/c/cmdline.lua index b6fd766b..7ff9d445 100644 --- a/pkgs/c/cmdline.lua +++ b/pkgs/c/cmdline.lua @@ -1,8 +1,9 @@ -- Form B (inline mcpp = { ... }) carries the build info for ALL listed versions. -- 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 identical across 0.0.1 --- and 0.0.2, so a single Form B block describes both versions correctly. +-- workaround table here. The src/**/*.cppm layout is the same across 0.0.1, +-- 0.0.2 and 0.0.3 (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"`. -- -- M6.x: Form B paths are globs relative to the verdir (the untouched @@ -33,6 +34,13 @@ package = { }, sha256 = "4f3e2b8dc4d9f11bdd9a784a9914e889234ac305e1020282ffa03f506b75d52a", }, + ["0.0.3"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.3.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.3/cmdline-0.0.3.tar.gz", + }, + sha256 = "a7854898e083f6df203ef7f14ec668812f3a5c28739fdc84d05d9dc39b990ca0", + }, }, macosx = { ["0.0.1"] = { @@ -49,6 +57,13 @@ package = { }, sha256 = "4f3e2b8dc4d9f11bdd9a784a9914e889234ac305e1020282ffa03f506b75d52a", }, + ["0.0.3"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.3.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.3/cmdline-0.0.3.tar.gz", + }, + sha256 = "a7854898e083f6df203ef7f14ec668812f3a5c28739fdc84d05d9dc39b990ca0", + }, }, windows = { ["0.0.1"] = { @@ -65,6 +80,13 @@ package = { }, sha256 = "4f3e2b8dc4d9f11bdd9a784a9914e889234ac305e1020282ffa03f506b75d52a", }, + ["0.0.3"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.3.tar.gz", + CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.3/cmdline-0.0.3.tar.gz", + }, + sha256 = "a7854898e083f6df203ef7f14ec668812f3a5c28739fdc84d05d9dc39b990ca0", + }, }, }, diff --git a/tests/examples/cmdline/mcpp.toml b/tests/examples/cmdline/mcpp.toml index 95931076..e5d39a46 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] -cmdline = "0.0.2" +cmdline = "0.0.3" diff --git a/tests/examples/cmdline/tests/consume.cpp b/tests/examples/cmdline/tests/consume.cpp index cd881922..942017b4 100644 --- a/tests/examples/cmdline/tests/consume.cpp +++ b/tests/examples/cmdline/tests/consume.cpp @@ -41,6 +41,13 @@ int main() { check(!missing.has_value() || missing.error().is_error(), "a missing required argument is refused"); + // 0.0.3: a numeric option is checked by the parse and read back typed. + auto numbers = cmdline::App("tool").option(cmdline::Option("rate").value_type()).option(cmdline::Option("count").value_type()); + auto typed = numbers.parse_from("tool --rate 2.5 --count=3"); + check(typed && typed->value_as("rate") == 2.5 && typed->value_as("count") == 3, "numbers read back as their types"); + 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"); + if (failures == 0) std::println("cmdline: ok"); return failures == 0 ? 0 : 1; } From e2d4895e3dde2f0f47dadb8b06cf73a2274ffc4e Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 9 Nov 2026 16:06:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?tests/examples/cmdline:=20the=20dependency?= =?UTF-8?q?=20by=20its=20identity,=20mcpplibs.cmdline=20=E2=80=94=20what?= =?UTF-8?q?=20the=20scan=20finds=20a=20candidate's=20consumer=20by?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/examples/cmdline/mcpp.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/examples/cmdline/mcpp.toml b/tests/examples/cmdline/mcpp.toml index e5d39a46..7867f58b 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] -cmdline = "0.0.3" +mcpplibs.cmdline = "0.0.3"