mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-03 05:53:52 +00:00
Extra subcommand print (#1058)
Fixes issue #1045 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
3afddf3578
commit
7be1740521
@ -26,7 +26,7 @@ repos:
|
|||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: v18.1.6
|
rev: v18.1.8
|
||||||
hooks:
|
hooks:
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
types_or: [c++, c, cuda]
|
types_or: [c++, c, cuda]
|
||||||
|
@ -49,14 +49,17 @@ jobs:
|
|||||||
Linux14PC:
|
Linux14PC:
|
||||||
vmImage: "ubuntu-latest"
|
vmImage: "ubuntu-latest"
|
||||||
cli11.precompile: ON
|
cli11.precompile: ON
|
||||||
|
macOS20:
|
||||||
|
vmImage: "macOS-14"
|
||||||
|
cli11.std: 20
|
||||||
macOS17:
|
macOS17:
|
||||||
vmImage: "macOS-12"
|
vmImage: "macOS-13"
|
||||||
cli11.std: 17
|
cli11.std: 17
|
||||||
macOS11:
|
macOS11:
|
||||||
vmImage: "macOS-11"
|
vmImage: "macOS-12"
|
||||||
cli11.std: 11
|
cli11.std: 11
|
||||||
macOS11PC:
|
macOS12PC:
|
||||||
vmImage: "macOS-11"
|
vmImage: "macOS-12"
|
||||||
cli11.std: 11
|
cli11.std: 11
|
||||||
cli11.precompile: ON
|
cli11.precompile: ON
|
||||||
Windows17:
|
Windows17:
|
||||||
|
@ -180,10 +180,10 @@ CLI11_INLINE std::string Formatter::make_subcommands(const App *app, AppFormatMo
|
|||||||
std::vector<std::string> subcmd_groups_seen;
|
std::vector<std::string> subcmd_groups_seen;
|
||||||
for(const App *com : subcommands) {
|
for(const App *com : subcommands) {
|
||||||
if(com->get_name().empty()) {
|
if(com->get_name().empty()) {
|
||||||
if(com->get_group().empty() || com->get_group().front() == '+') {
|
if(!com->get_group().empty() && com->get_group().front() != '+') {
|
||||||
continue;
|
out << make_expanded(com);
|
||||||
}
|
}
|
||||||
out << make_expanded(com);
|
continue;
|
||||||
}
|
}
|
||||||
std::string group_key = com->get_group();
|
std::string group_key = com->get_group();
|
||||||
if(!group_key.empty() &&
|
if(!group_key.empty() &&
|
||||||
|
@ -273,6 +273,35 @@ TEST_CASE("THelp: HiddenGroup", "[help]") {
|
|||||||
CHECK_THAT(help, Contains("another"));
|
CHECK_THAT(help, Contains("another"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// from https://github.com/CLIUtils/CLI11/issues/1045
|
||||||
|
TEST_CASE("THelp: multiple_group", "[help]") {
|
||||||
|
CLI::App app{"test_group"};
|
||||||
|
auto *group1 = app.add_option_group("outGroup");
|
||||||
|
auto *group2 = app.add_option_group("inGroup");
|
||||||
|
|
||||||
|
std::string outFile("");
|
||||||
|
group1->add_option("--outfile,-o", outFile, "specify the file location of the output")->required();
|
||||||
|
|
||||||
|
std::string inFile("");
|
||||||
|
group2->add_option("--infile,-i", inFile, "specify the file location of the input")->required();
|
||||||
|
|
||||||
|
auto help = app.help();
|
||||||
|
int inCount = 0;
|
||||||
|
int outCount = 0;
|
||||||
|
auto iFind = help.find("inGroup");
|
||||||
|
while(iFind != std::string::npos) {
|
||||||
|
++inCount;
|
||||||
|
iFind = help.find("inGroup", iFind + 6);
|
||||||
|
}
|
||||||
|
auto oFind = help.find("outGroup");
|
||||||
|
while(oFind != std::string::npos) {
|
||||||
|
++outCount;
|
||||||
|
oFind = help.find("outGroup", oFind + 6);
|
||||||
|
}
|
||||||
|
CHECK(inCount == 1);
|
||||||
|
CHECK(outCount == 1);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("THelp: OptionalPositionalAndOptions", "[help]") {
|
TEST_CASE("THelp: OptionalPositionalAndOptions", "[help]") {
|
||||||
CLI::App app{"My prog", "AnotherProgram"};
|
CLI::App app{"My prog", "AnotherProgram"};
|
||||||
app.add_flag("-q,--quick");
|
app.add_flag("-q,--quick");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user