Suppress "Available top-level options:" if none available
This commit is contained in:
parent
5c098df8d7
commit
9cc6be4d4c
|
@ -814,10 +814,14 @@ void ArgumentParser::printHelp(ostream &os) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_mainArgs.empty()) {
|
if (!m_mainArgs.empty()) {
|
||||||
bool hasOperations = false;
|
bool hasOperations = false, hasTopLevelOptions = false;
|
||||||
for (const Argument *const arg : m_mainArgs) {
|
for (const Argument *const arg : m_mainArgs) {
|
||||||
if (arg->denotesOperation()) {
|
if (arg->denotesOperation()) {
|
||||||
hasOperations = true;
|
hasOperations = true;
|
||||||
|
} else if (strcmp(arg->name(), "help")) {
|
||||||
|
hasTopLevelOptions = true;
|
||||||
|
}
|
||||||
|
if (hasOperations && hasTopLevelOptions) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -833,13 +837,15 @@ void ArgumentParser::printHelp(ostream &os) const
|
||||||
os << '\n';
|
os << '\n';
|
||||||
arg->printInfo(os);
|
arg->printInfo(os);
|
||||||
}
|
}
|
||||||
os << "\nAvailable top-level options:";
|
if (hasTopLevelOptions) {
|
||||||
for (const Argument *const arg : m_mainArgs) {
|
os << "\nAvailable top-level options:";
|
||||||
if (arg->denotesOperation() || arg->isDeprecated() || !strcmp(arg->name(), "help")) {
|
for (const Argument *const arg : m_mainArgs) {
|
||||||
continue;
|
if (arg->denotesOperation() || arg->isDeprecated() || !strcmp(arg->name(), "help")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
os << '\n';
|
||||||
|
arg->printInfo(os);
|
||||||
}
|
}
|
||||||
os << '\n';
|
|
||||||
arg->printInfo(os);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// just show all args if no operations are available
|
// just show all args if no operations are available
|
||||||
|
|
Loading…
Reference in New Issue