Skip to content

Commit

Permalink
[cl] Don't print subcommand help when no subcommands present.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Zachary Turner committed Oct 11, 2016
1 parent b3c22e4 commit ed36d63
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1756,10 +1756,12 @@ class HelpPrinter {
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";
Expand Down

0 comments on commit ed36d63

Please sign in to comment.