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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 23 additions & 2 deletions pkgs/c/cmdline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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"`.
--
Expand Down Expand Up @@ -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"] = {
Expand Down Expand Up @@ -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"] = {
Expand Down Expand Up @@ -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",
},
},
},

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]
mcpplibs.cmdline = "0.0.6"
mcpplibs.cmdline = "0.0.7"
13 changes: 13 additions & 0 deletions tests/examples/cmdline/tests/consume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> listed;
for (const auto& c : cmdline::snapshot(grouped).subcommands) listed.push_back(c.name);
check(listed == std::vector<std::string>{"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;
}
Loading