/// Render the help text for an option table.
///
/// \param OS - The stream to write the help text to.
- /// \param Name - The name to use in the usage line.
- /// \param Title - The title to use in the usage line.
+ /// \param Usage - USAGE: Usage
+ /// \param Title - OVERVIEW: Title
/// \param FlagsToInclude - If non-zero, only include options with any
/// of these flags set.
/// \param FlagsToExclude - Exclude options with any of these flags set.
/// that don't have help texts. By default, we display
/// only options that are not hidden and have help
/// texts.
- void PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+ void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
unsigned FlagsToInclude, unsigned FlagsToExclude,
bool ShowAllAliases) const;
- void PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+ void PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
bool ShowHidden = false, bool ShowAllAliases = false) const;
};
return getOptionHelpGroup(Opts, GroupID);
}
-void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
bool ShowHidden, bool ShowAllAliases) const {
- PrintHelp(OS, Name, Title, /*Include*/ 0, /*Exclude*/
+ PrintHelp(OS, Usage, Title, /*Include*/ 0, /*Exclude*/
(ShowHidden ? 0 : HelpHidden), ShowAllAliases);
}
-void OptTable::PrintHelp(raw_ostream &OS, const char *Name, const char *Title,
+void OptTable::PrintHelp(raw_ostream &OS, const char *Usage, const char *Title,
unsigned FlagsToInclude, unsigned FlagsToExclude,
bool ShowAllAliases) const {
- OS << "OVERVIEW: " << Title << "\n";
- OS << '\n';
- OS << "USAGE: " << Name << " [options] <inputs>\n";
- OS << '\n';
+ OS << "OVERVIEW: " << Title << "\n\n";
+ OS << "USAGE: " << Usage << "\n\n";
// Render help text into a map of group-name to a list of (option, help)
// pairs.
// Handle when no input or output is specified
if (Args.hasArgNoClaim(OPT_INPUT) ||
(!Args.hasArgNoClaim(OPT_d) && !Args.hasArgNoClaim(OPT_l))) {
- Table.PrintHelp(outs(), ArgsArr[0], "dlltool", false);
+ Table.PrintHelp(outs(), "llvm-dlltool [options] file...", "llvm-dlltool",
+ false);
llvm::outs() << "\nTARGETS: i386, i386:x86-64, arm, arm64\n";
return 1;
}
// Handle /help
if (Args.hasArg(OPT_help)) {
- Table.PrintHelp(outs(), ArgsArr[0], "LLVM Lib");
+ Table.PrintHelp(outs(), "llvm-lib [options] file...", "LLVM Lib");
return 0;
}
; RUN: FileCheck -input-file=%t %s -check-prefix=HELP_TEST
; HELP_TEST: OVERVIEW: Resource Converter
-; HELP_TEST-DAG: USAGE: cvtres [options] <inputs>
+; HELP_TEST-DAG: USAGE: llvm-cvtres [options] file...
; HELP_TEST-DAG: OPTIONS:
; HELP_TEST-NEXT: /DEFINE:symbol
; HELP_TEST-NEXT: /FOLDDUPS:
; RUN: FileCheck -input-file=%t1 %s
; CHECK: OVERVIEW: Resource Converter
-; CHECK-DAG: USAGE: rc [options] <inputs>
+; CHECK-DAG: USAGE: rc [options] file...
; CHECK-DAG: OPTIONS:
; CHECK-NEXT: /? Display this help and exit.
; CHECK-NEXT: /C <value> Set the codepage used for input strings.
opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
if (InputArgs.hasArg(OPT_HELP)) {
- T.PrintHelp(outs(), "cvtres", "Resource Converter", false);
+ T.PrintHelp(outs(), "llvm-cvtres [options] file...", "Resource Converter", false);
return 0;
}
}
if (InputArgs.hasArg(OPT_help)) {
- T.PrintHelp(outs(), "mt", "Manifest Tool", false);
+ T.PrintHelp(outs(), "llvm-mt [options] file...", "Manifest Tool", false);
return 0;
}
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
if (InputArgs.size() == 0) {
- T.PrintHelp(errs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
+ T.PrintHelp(errs(), "llvm-objcopy input [output]", "objcopy tool");
exit(1);
}
if (InputArgs.hasArg(OBJCOPY_help)) {
- T.PrintHelp(outs(), "llvm-objcopy <input> [ <output> ]", "objcopy tool");
+ T.PrintHelp(outs(), "llvm-objcopy input [output]", "objcopy tool");
exit(0);
}
llvm::opt::InputArgList InputArgs =
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
+ static const char Usage[] = "llvm-strip [options] file...";
if (InputArgs.size() == 0) {
- T.PrintHelp(errs(), "llvm-strip", "strip tool");
+ T.PrintHelp(errs(), Usage, "strip tool");
exit(1);
}
if (InputArgs.hasArg(STRIP_help)) {
- T.PrintHelp(outs(), "llvm-strip", "strip tool");
+ T.PrintHelp(outs(), Usage, "strip tool");
exit(0);
}
// The tool prints nothing when invoked with no command-line arguments.
if (InputArgs.hasArg(OPT_HELP)) {
- T.PrintHelp(outs(), "rc", "Resource Converter", false);
+ T.PrintHelp(outs(), "rc [options] file...", "Resource Converter", false);
return 0;
}
T.PrintHelp(RSO, "test", "title!");
EXPECT_NE(std::string::npos, Help.find("-A"));
+ // Check usage line.
+ T.PrintHelp(RSO, "name [options] file...", "title!");
+ EXPECT_NE(std::string::npos, Help.find("USAGE: name [options] file...\n"));
+
// Test aliases.
auto Cs = AL.filtered(OPT_C);
ASSERT_NE(Cs.begin(), Cs.end());