添加生成help功能

This commit is contained in:
2024-02-05 01:33:44 +08:00
parent f994bae5cb
commit ded5c77a70
3 changed files with 39 additions and 0 deletions

View File

@@ -97,3 +97,15 @@ TEST(Option, 匿名参数测试3) {
if (order.analysis())
ASSERT_FALSE("匿名参数数量超出限制,但是没有抛出异常!");
}
TEST(Option, Help生成) {
ling::Order order({"-pts", "hello world!", "hello!", "--all", "--ok", "world"});
order.addAnonymity(1);
const auto pts = order.addOption({"-pts", "--pts"}, ling::Order::Type::STRING, "测试参数");
const auto all = order.addOption({"-all", "--all"},"测试参数");
const auto ok = order.addOption({"-ok", "--ok"},"测试参数");
const auto cancel = order.addOption({"--cancel"},"测试参数");
auto help = order.generateHelp("test [选项] .. [参数]\n测试命令");
std::cout << help << std::endl;
}