Commit 8020279d authored by Brad King's avatar Brad King
Browse files

ENH: Added --help-list-commands option.

parent 6174100b
......@@ -27,6 +27,10 @@ static const cmDocumentationEntry cmDocumentationStandardOptions[] =
"Usage describes the basic command line interface and its options. "
"If a listfile command is specified, help for that specific command is "
"printed."},
{"--help-list-commands [file]", "List available listfile commands and exit.",
"The list contains all commands for which help may be obtained by using "
"the --help argument followed by a command name. If a file is specified, "
"the help is written into it."},
{"--help-full [file]", "Print full help and exit.",
"Full help displays most of the documentation provided by the UNIX "
"man page. It is provided for use on non-UNIX platforms, but is "
......@@ -175,6 +179,7 @@ void cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
switch (ht)
{
case cmDocumentation::Usage: this->PrintDocumentationUsage(os); break;
case cmDocumentation::List: this->PrintDocumentationList(os); break;
case cmDocumentation::Full: this->PrintDocumentationFull(os); break;
case cmDocumentation::HTML: this->PrintDocumentationHTML(os); break;
case cmDocumentation::Man: this->PrintDocumentationMan(os); break;
......@@ -211,7 +216,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
// Argument was not a command. Complain.
os << "Help argument \"" << i->second.c_str()
<< "\" is not a CMake command. "
<< "Use --help-full to see all commands.\n";
<< "Use --help-list-commands to see all commands.\n";
return false;
}
......@@ -287,6 +292,10 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
{
type = cmDocumentation::Man;
}
else if(strcmp(argv[i], "--help-list-commands") == 0)
{
type = cmDocumentation::List;
}
else if(strcmp(argv[i], "--copyright") == 0)
{
type = cmDocumentation::Copyright;
......@@ -525,7 +534,7 @@ void cmDocumentation::PrintSectionUsage(std::ostream& os,
if(op->name)
{
os << " " << op->name;
this->TextIndent = " ";
this->TextIndent = " ";
int align = static_cast<int>(strlen(this->TextIndent))-4;
for(int i = static_cast<int>(strlen(op->name)); i < align; ++i)
{
......@@ -791,6 +800,19 @@ void cmDocumentation::PrintDocumentationUsage(std::ostream& os)
this->Print(UsageForm, os);
}
//----------------------------------------------------------------------------
void cmDocumentation::PrintDocumentationList(std::ostream& os)
{
for(cmDocumentationEntry* entry = &this->CommandsSection[0];
entry->brief; ++entry)
{
if(entry->name)
{
os << entry->name << std::endl;
}
}
}
//----------------------------------------------------------------------------
void cmDocumentation::PrintDocumentationFull(std::ostream& os)
{
......
......@@ -28,7 +28,7 @@ public:
// High-level interface for standard documents:
/** Types of help provided. */
enum Type { None, Usage, Full, HTML, Man, Copyright, Version };
enum Type { None, Usage, List, Full, HTML, Man, Copyright, Version };
/**
* Check command line arguments for documentation options. Returns
......@@ -124,6 +124,7 @@ private:
void PrintCopyright(std::ostream& os);
void PrintVersion(std::ostream& os);
void PrintDocumentationUsage(std::ostream& os);
void PrintDocumentationList(std::ostream& os);
void PrintDocumentationFull(std::ostream& os);
void PrintDocumentationHTML(std::ostream& os);
void PrintDocumentationMan(std::ostream& os);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment