Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

### Added

- **mcpplibs.cmdline 0.0.3.** `value_type<T>()` 声明选项取 `T` 类型的数字,解析时用 `std::from_chars` 校验,不合法即解析错误;
`value_as<T>()` 读回。测试成员移到 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`
Expand Down
26 changes: 24 additions & 2 deletions pkgs/c/cmdline.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"] = {
Expand All @@ -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"] = {
Expand All @@ -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",
},
},
},

Expand Down
2 changes: 1 addition & 1 deletion tests/examples/cmdline/mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ name = "cmdline-tests"
version = "0.1.0"

[dependencies]
cmdline = "0.0.2"
mcpplibs.cmdline = "0.0.3"
7 changes: 7 additions & 0 deletions tests/examples/cmdline/tests/consume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>()).option(cmdline::Option("count").value_type<int>());
auto typed = numbers.parse_from("tool --rate 2.5 --count=3");
check(typed && typed->value_as<double>("rate") == 2.5 && typed->value_as<int>("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;
}
Loading