mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
Per code review:
*Implement/Document the cl::extrahelp feature instead of the MoreHelp ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17871 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
eea9b134fc
commit
9bbba09139
@ -2,6 +2,7 @@
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>CommandLine 2.0 Library Manual</title>
|
||||
<link rel="stylesheet" href="llvm.css" type="text/css">
|
||||
</head>
|
||||
@ -61,6 +62,7 @@
|
||||
<li><a href="#cl::opt">The <tt>cl::opt</tt> class</a></li>
|
||||
<li><a href="#cl::list">The <tt>cl::list</tt> class</a></li>
|
||||
<li><a href="#cl::alias">The <tt>cl::alias</tt> class</a></li>
|
||||
<li><a href="#cl::extrahelp">The <tt>cl::extrahelp</tt> class</a></li>
|
||||
</ul></li>
|
||||
|
||||
<li><a href="#builtinparsers">Builtin parsers</a>
|
||||
@ -1519,6 +1521,34 @@ the conversion from string to data.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- _______________________________________________________________________ -->
|
||||
<div class="doc_subsubsection">
|
||||
<a name="cl::extrahelp">The <tt>cl::extrahelp</tt> class</a>
|
||||
</div>
|
||||
|
||||
<div class="doc_text">
|
||||
|
||||
<p>The <tt>cl::extrahelp</tt> class is a nontemplated class that allows extra
|
||||
help text to be printed out for the <tt>--help</tt> option.</p>
|
||||
|
||||
<pre>
|
||||
<b>namespace</b> cl {
|
||||
<b>struct</b> extrahelp;
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>To use the extrahelp, simply construct one with a <tt>const char*</tt>
|
||||
parameter to the constructor. The text passed to the constructor will be printed
|
||||
at the bottom of the help message, verbatim. Note that multiple
|
||||
<tt>cl::extrahelp</tt> <b>can</b> be used but this practice is discouraged. If
|
||||
your tool needs to print additional help information, put all that help into a
|
||||
single <tt>cl::extrahelp</tt> instance.</p>
|
||||
<p>For example:</p>
|
||||
<pre>
|
||||
cl::extrahelp("\nADDITIONAL HELP:\n\n This is the extra help\n");
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<!-- ======================================================================= -->
|
||||
<div class="doc_subsection">
|
||||
<a name="builtinparsers">Builtin parsers</a>
|
||||
|
@ -1046,13 +1046,19 @@ struct aliasopt {
|
||||
void apply(alias &A) const { A.setAliasFor(Opt); }
|
||||
};
|
||||
|
||||
/// Permit the tool to provide additional help output after the normal
|
||||
/// help output. To use this, create a function that returns void and
|
||||
/// takes no arguments. Assign its address to cl::MoreHelp. If set,
|
||||
/// this function will be called just before the CommandLine exits
|
||||
/// after printing the help.
|
||||
/// @brief Optional pointer to additional help function
|
||||
extern void (*MoreHelp)();
|
||||
// extrahelp - provide additional help at the end of the normal help
|
||||
// output. All occurrences of cl::extrahelp will be accumulated and
|
||||
// printed to std::cerr at the end of the regular help, just before
|
||||
// exit is called.
|
||||
struct extrahelp {
|
||||
const char * morehelp;
|
||||
extrahelp(const char* help);
|
||||
};
|
||||
|
||||
// This function just prints the help message, exactly the same way as if the
|
||||
// --help option had been given on the command line.
|
||||
// NOTE: THIS FUNCTION TERMINATES THE PROGRAM!
|
||||
void PrintHelpMessage();
|
||||
|
||||
} // End namespace cl
|
||||
|
||||
|
@ -838,7 +838,15 @@ void generic_parser_base::printOptionInfo(const Option &O,
|
||||
// If this variable is set, it is a pointer to a function that the user wants
|
||||
// us to call after we print out the help info. Basically a hook to allow
|
||||
// additional help to be printed.
|
||||
void (*cl::MoreHelp)() = 0;
|
||||
static std::vector<const char*>* MoreHelp = 0;
|
||||
|
||||
extrahelp::extrahelp(const char* Help)
|
||||
: morehelp(Help) {
|
||||
if (!MoreHelp) {
|
||||
MoreHelp = new std::vector<const char*>;
|
||||
}
|
||||
MoreHelp->push_back(Help);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@ -913,11 +921,16 @@ public:
|
||||
for (unsigned i = 0, e = Options.size(); i != e; ++i)
|
||||
Options[i].second->printOptionInfo(MaxArgLen);
|
||||
|
||||
// Call the user's hook so help output can be extended.
|
||||
if (MoreHelp != 0)
|
||||
(*MoreHelp)();
|
||||
// Print any extra help the user has declared. If MoreHelp is not null,
|
||||
// then the user used at least one cl::extrahelp instance to provide
|
||||
// additional help. We just print it out now.
|
||||
if (MoreHelp != 0) {
|
||||
for (std::vector<const char *>::iterator I = MoreHelp->begin(),
|
||||
E = MoreHelp->end(); I != E; ++I)
|
||||
std::cerr << *I;
|
||||
}
|
||||
|
||||
// Halt the program if help information is printed
|
||||
// Halt the program since help information was printed
|
||||
exit(1);
|
||||
}
|
||||
};
|
||||
@ -954,4 +967,10 @@ cl::opt<VersionPrinter, true, parser<bool> >
|
||||
VersOp("version", cl::desc("display the version"),
|
||||
cl::location(VersionPrinterInstance), cl::ValueDisallowed);
|
||||
|
||||
|
||||
} // End anonymous namespace
|
||||
|
||||
// Utility function for printing the help message.
|
||||
void cl::PrintHelpMessage() {
|
||||
NormalPrinter = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user