Browse Source

Merge topic 'cmake-no-args-output'

de7c2882 cmake,ccmake: Produce shorter output on no arguments (#14973)
Brad King 11 years ago
parent
commit
94d1879ba0

+ 16 - 0
Source/CursesDialog/ccmake.cxx

@@ -38,6 +38,18 @@ static const char * cmDocumentationUsage[][2] =
   {0,
    "  ccmake <path-to-source>\n"
    "  ccmake <path-to-existing-build>"},
+  {0,
+   "Specify a source directory to (re-)generate a build system for "
+   "it in the current working directory.  Specify an existing build "
+   "directory to re-generate its build system."},
+  {0,0}
+};
+
+//----------------------------------------------------------------------------
+static const char * cmDocumentationUsageNote[][2] =
+{
+  {0,
+   "Run 'ccmake --help' for more information."},
   {0,0}
 };
 
@@ -102,6 +114,10 @@ int main(int argc, char const* const* argv)
     doc.SetName("ccmake");
     doc.SetSection("Name",cmDocumentationName);
     doc.SetSection("Usage",cmDocumentationUsage);
+    if ( argc == 1 )
+      {
+      doc.AppendSection("Usage",cmDocumentationUsageNote);
+      }
     doc.SetSection("Generators",generators);
     doc.PrependSection("Options",cmDocumentationOptions);
     return doc.PrintRequestedDocumentation(std::cout)? 0:1;

+ 17 - 3
Source/cmDocumentation.cxx

@@ -113,7 +113,9 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
   switch (ht)
     {
     case cmDocumentation::Usage:
-      return this->PrintDocumentationUsage(os);
+      return this->PrintUsage(os);
+    case cmDocumentation::Help:
+      return this->PrintHelp(os);
     case cmDocumentation::Full:
       return this->PrintHelpFull(os);
     case cmDocumentation::OneManual:
@@ -300,7 +302,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
        (strcmp(argv[i], "-h") == 0) ||
        (strcmp(argv[i], "-H") == 0))
       {
-      help.HelpType = cmDocumentation::Usage;
+      help.HelpType = cmDocumentation::Help;
       GET_OPT_ARGUMENT(help.Argument);
       help.Argument = cmSystemTools::LowerCase(help.Argument);
       // special case for single command
@@ -841,7 +843,19 @@ bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
 }
 
 //----------------------------------------------------------------------------
-bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
+bool cmDocumentation::PrintUsage(std::ostream& os)
+{
+  std::map<std::string,cmDocumentationSection*>::iterator si;
+  si = this->AllSections.find("Usage");
+  if(si != this->AllSections.end())
+    {
+    this->Formatter.PrintSection(os, *si->second);
+    }
+  return true;
+}
+
+//----------------------------------------------------------------------------
+bool cmDocumentation::PrintHelp(std::ostream& os)
 {
   std::map<std::string,cmDocumentationSection*>::iterator si;
   si = this->AllSections.find("Usage");

+ 2 - 1
Source/cmDocumentation.h

@@ -102,6 +102,8 @@ private:
   bool PrintFiles(std::ostream& os, std::string const& pattern);
 
   bool PrintVersion(std::ostream& os);
+  bool PrintUsage(std::ostream& os);
+  bool PrintHelp(std::ostream& os);
   bool PrintHelpFull(std::ostream& os);
   bool PrintHelpOneManual(std::ostream& os);
   bool PrintHelpOneCommand(std::ostream& os);
@@ -115,7 +117,6 @@ private:
   bool PrintHelpListProperties(std::ostream& os);
   bool PrintHelpListVariables(std::ostream& os);
   bool PrintHelpListPolicies(std::ostream& os);
-  bool PrintDocumentationUsage(std::ostream& os);
   bool PrintOldCustomModules(std::ostream& os);
 
   const char* GetNameString() const;

+ 1 - 1
Source/cmDocumentationFormatter.h

@@ -26,7 +26,7 @@ public:
   /** Types of help provided.  */
   enum Type
   {
-    None, Version, Usage, Full, ListManuals,
+    None, Version, Usage, Help, Full, ListManuals,
     ListCommands, ListModules, ListProperties, ListVariables, ListPolicies,
     OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy,
     OldCustomModules

+ 16 - 0
Source/cmakemain.cxx

@@ -42,6 +42,18 @@ static const char * cmDocumentationUsage[][2] =
   {0,
    "  cmake [options] <path-to-source>\n"
    "  cmake [options] <path-to-existing-build>"},
+  {0,
+   "Specify a source directory to (re-)generate a build system for "
+   "it in the current working directory.  Specify an existing build "
+   "directory to re-generate its build system."},
+  {0,0}
+};
+
+//----------------------------------------------------------------------------
+static const char * cmDocumentationUsageNote[][2] =
+{
+  {0,
+   "Run 'cmake --help' for more information."},
   {0,0}
 };
 
@@ -223,6 +235,10 @@ int do_cmake(int ac, char const* const* av)
     doc.SetName("cmake");
     doc.SetSection("Name",cmDocumentationName);
     doc.SetSection("Usage",cmDocumentationUsage);
+    if ( ac == 1 )
+      {
+      doc.AppendSection("Usage",cmDocumentationUsageNote);
+      }
     doc.AppendSection("Generators",generators);
     doc.PrependSection("Options",cmDocumentationOptions);