[cl] Don't print subcommand help when no subcommands present.

Previously we would print

  USAGE: <exe> [subcommand] [options]

Even if no subcommands were present.  This changes the output
format to only print "[subcommand]" if there is at least one
subcommand.

Fixes llvm.org/pr30598

Patch by Serge Guelton

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283892 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zachary Turner 2016-10-11 15:58:48 +00:00
parent b3c22e4e95
commit ed36d63443

View File

@ -1756,10 +1756,12 @@ public:
if (!GlobalParser->ProgramOverview.empty())
outs() << "OVERVIEW: " << GlobalParser->ProgramOverview << "\n";
if (Sub == &*TopLevelSubCommand)
outs() << "USAGE: " << GlobalParser->ProgramName
<< " [subcommand] [options]";
else {
if (Sub == &*TopLevelSubCommand) {
outs() << "USAGE: " << GlobalParser->ProgramName;
if (Subs.size() > 2)
outs() << " [subcommand]";
outs() << " [options]";
} else {
if (!Sub->getDescription().empty()) {
outs() << "SUBCOMMAND '" << Sub->getName()
<< "': " << Sub->getDescription() << "\n\n";