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

This commit is contained in:
Brad King 2004-04-14 13:40:24 -04:00
parent 6174100b92
commit 8020279dd6
2 changed files with 26 additions and 3 deletions

View File

@ -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)
{

View File

@ -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);