Do not show help for --help

This commit is contained in:
Martchus 2018-01-28 00:43:03 +01:00
parent 09f9181281
commit ff5eb6c7c9
2 changed files with 6 additions and 8 deletions

View File

@ -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);
}
}
}
}

View File

@ -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"