From ff5eb6c7c918b5df3e4c9357cd0d9383d4d403f5 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sun, 28 Jan 2018 00:43:03 +0100 Subject: [PATCH] Do not show help for --help --- application/argumentparser.cpp | 10 ++++++---- tests/argumentparsertests.cpp | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/application/argumentparser.cpp b/application/argumentparser.cpp index ba7bd9d..f4bdac4 100644 --- a/application/argumentparser.cpp +++ b/application/argumentparser.cpp @@ -730,14 +730,14 @@ void ArgumentParser::printHelp(ostream &os) const // split top-level operations and other configurations os << "Available operations:"; for (const Argument *arg : m_mainArgs) { - if (arg->denotesOperation()) { + if (arg->denotesOperation() && strcmp(arg->name(), "help")) { os << '\n'; arg->printInfo(os); } } os << "\nAvailable top-level options:"; for (const Argument *arg : m_mainArgs) { - if (!arg->denotesOperation()) { + if (!arg->denotesOperation() && strcmp(arg->name(), "help")) { os << '\n'; arg->printInfo(os); } @@ -746,8 +746,10 @@ void ArgumentParser::printHelp(ostream &os) const // just show all args if no operations are available os << "Available arguments:"; for (const Argument *arg : m_mainArgs) { - os << '\n'; - arg->printInfo(os); + if (strcmp(arg->name(), "help")) { + os << '\n'; + arg->printInfo(os); + } } } } diff --git a/tests/argumentparsertests.cpp b/tests/argumentparsertests.cpp index ae518ad..1b2a0e1 100644 --- a/tests/argumentparsertests.cpp +++ b/tests/argumentparsertests.cpp @@ -685,10 +685,6 @@ void ArgumentParserTests::testHelp() " example: actually not an operation\n" "\n" "Available top-level options:\n" - "\e[1m--help, -h\e[0m\n" - " shows this information\n" - " particularities: mandatory\n" - "\n" "\e[1m--files, -f\e[0m\n" " specifies the path of the file(s) to be opened\n" " \e[1m--sub\e[0m\n"