From 8020279dd602626ae8edeaa3553d2cd391818e0f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2004 13:40:24 -0400 Subject: [PATCH] ENH: Added --help-list-commands option. --- Source/cmDocumentation.cxx | 26 ++++++++++++++++++++++++-- Source/cmDocumentation.h | 3 ++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 5651c2ca8..0a1ceacd2 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -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(strlen(this->TextIndent))-4; for(int i = static_cast(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) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 3a0ac18e2..79023bcaa 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -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);