Skip to content

Commit 417ea59

Browse files
authored
mcpplibs.cmdline 0.0.5: snapshot(app) is exported (#865)
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...).
1 parent b55f8af commit 417ea59

4 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎CHANGELOG.md‎

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

1010
### Added
1111

12+
- **mcpplibs.cmdline 0.0.5.** `snapshot(const App&)` 是导出的函数,与 docs/api.md 所述一致:程序由解析它所用的定义列出自身的
13+
命令与选项(mcpp 的 `mcpp emit surface`)。测试成员移到 0.0.5,并检验这一项。
1214
- **mtest 0.11.0(mcpplibs.mtest、.manifest、.gtest、.capi)与新包 mcpplibs.mtest.doctest。** 协议的 `step` 与 `exercise` 事件(P5.6);
1315
用例结束时检查它启动的进程与诊断行;机器的一份预算(O11)与抖动(O12);运行记录机器的类别;`[budget]` 与 `[ledger.*]`
1416
由门禁判定;GCC 上一个文件的首个用例与期望由 689 ms 降为 265 ms。`mcpplibs.mtest.doctest` 是 doctest 的协议适配器(1 级),

‎pkgs/c/cmdline.lua‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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 and 0.0.4 (0.0.3 adds src/completions*.cppm, which the glob takes in),
5+
-- 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),
66
-- so a single Form B block describes every version correctly.
77
-- When 0.0.1 is dropped, this can be replaced with `mcpp = "*/mcpp.toml"`.
88
--
@@ -48,6 +48,13 @@ package = {
4848
},
4949
sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a",
5050
},
51+
["0.0.5"] = {
52+
url = {
53+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz",
54+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz",
55+
},
56+
sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf",
57+
},
5158
},
5259
macosx = {
5360
["0.0.1"] = {
@@ -78,6 +85,13 @@ package = {
7885
},
7986
sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a",
8087
},
88+
["0.0.5"] = {
89+
url = {
90+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz",
91+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz",
92+
},
93+
sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf",
94+
},
8195
},
8296
windows = {
8397
["0.0.1"] = {
@@ -108,6 +122,13 @@ package = {
108122
},
109123
sha256 = "8428e829bec2f74b2841b33fc2f319cdd1316bdcd7a6c5839bdc641c7e85fd1a",
110124
},
125+
["0.0.5"] = {
126+
url = {
127+
GLOBAL = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.0.5.tar.gz",
128+
CN = "https://gitcode.com/mcpp-res/cmdline/releases/download/0.0.5/cmdline-0.0.5.tar.gz",
129+
},
130+
sha256 = "a8fad9858ffaa6399f299f7b66c042cb0632d9139f8b917c5b35b9add1885abf",
131+
},
111132
},
112133
},
113134

‎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.3"
13+
mcpplibs.cmdline = "0.0.5"

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ int main() {
4848
auto wrong = numbers.parse_from("tool --count 3px");
4949
check(!wrong && wrong.error().is_error(), "a value that is not a number of the type is refused");
5050

51+
// 0.0.5: the command tree is exported; a program lists its own commands and options from it.
52+
auto tree = cmdline::snapshot(cmdline::App("tool").subcommand(cmdline::App("add").option(cmdline::Option("force"))));
53+
check(tree.subcommands.size() == 1 && tree.subcommands[0].name == "add"
54+
&& !tree.subcommands[0].options.empty() && tree.subcommands[0].options[0].long_name == "force",
55+
"snapshot names each subcommand and its options");
56+
5157
if (failures == 0) std::println("cmdline: ok");
5258
return failures == 0 ? 0 : 1;
5359
}

0 commit comments

Comments
 (0)