Attached Files | 0001-Produce-shorter-output-on-no-arguments.patch [^] (5,752 bytes) 2014-06-12 14:57 [Show Content] [Hide Content]From db49efb24cc3fdfc99400447fe96f3b554ed63ab Mon Sep 17 00:00:00 2001
From: Adam Strzelecki <ono@java.pl>
Date: Thu, 12 Jun 2014 20:52:01 +0200
Subject: [PATCH] Produce shorter output on no arguments
Instead printing complete help cmake/ccmake now prints only Usage section and
extra Hint section giving information how to get more help or start your build.
---
Source/CursesDialog/ccmake.cxx | 12 ++++++++++++
Source/cmDocumentation.cxx | 21 ++++++++++++++++++++-
Source/cmDocumentation.h | 1 +
Source/cmDocumentationFormatter.h | 2 +-
Source/cmakemain.cxx | 12 ++++++++++++
5 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index a9d4d98..6ec7a2a 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -42,6 +42,17 @@ static const char * cmDocumentationUsage[][2] =
};
//----------------------------------------------------------------------------
+static const char * cmDocumentationHint[][2] =
+{
+ {0,
+ " ccmake . for in-source build (not recommended)\n"
+ " ccmake .. for out-of-source build inside subfolder\n"
+ " ccmake --help for more information\n"
+ "Note: Building in separate folder leaves source files intact."},
+ {0,0}
+};
+
+//----------------------------------------------------------------------------
static const char * cmDocumentationOptions[][2] =
{
CMAKE_STANDARD_OPTIONS_TABLE,
@@ -102,6 +113,7 @@ int main(int argc, char const* const* argv)
doc.SetName("ccmake");
doc.SetSection("Name",cmDocumentationName);
doc.SetSection("Usage",cmDocumentationUsage);
+ doc.SetSection("Hint",cmDocumentationHint);
doc.SetSection("Generators",generators);
doc.PrependSection("Options",cmDocumentationOptions);
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 8d035af..e208073 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -112,6 +112,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
{
switch (ht)
{
+ case cmDocumentation::Brief:
+ return this->PrintDocumentationBrief(os);
case cmDocumentation::Usage:
return this->PrintDocumentationUsage(os);
case cmDocumentation::Full:
@@ -277,7 +279,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
if(argc == 1)
{
RequestedHelpItem help;
- help.HelpType = cmDocumentation::Usage;
+ help.HelpType = cmDocumentation::Brief;
this->RequestedHelpItems.push_back(help);
return true;
}
@@ -841,6 +843,23 @@ bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
}
//----------------------------------------------------------------------------
+bool cmDocumentation::PrintDocumentationBrief(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);
+ }
+ si = this->AllSections.find("Hint");
+ if(si != this->AllSections.end())
+ {
+ this->Formatter.PrintSection(os, *si->second);
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
{
std::map<std::string,cmDocumentationSection*>::iterator si;
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index c98e48e..f116fe0 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -115,6 +115,7 @@ private:
bool PrintHelpListProperties(std::ostream& os);
bool PrintHelpListVariables(std::ostream& os);
bool PrintHelpListPolicies(std::ostream& os);
+ bool PrintDocumentationBrief(std::ostream& os);
bool PrintDocumentationUsage(std::ostream& os);
bool PrintOldCustomModules(std::ostream& os);
diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h
index 61766b9..7247244 100644
--- a/Source/cmDocumentationFormatter.h
+++ b/Source/cmDocumentationFormatter.h
@@ -26,7 +26,7 @@ public:
/** Types of help provided. */
enum Type
{
- None, Version, Usage, Full, ListManuals,
+ None, Version, Brief, Usage, Full, ListManuals,
ListCommands, ListModules, ListProperties, ListVariables, ListPolicies,
OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy,
OldCustomModules
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 9f9f6bb..fdc10a2 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -45,6 +45,17 @@ static const char * cmDocumentationUsage[][2] =
{0,0}
};
+//----------------------------------------------------------------------------
+static const char * cmDocumentationHint[][2] =
+{
+ {0,
+ " cmake . for in-source build (not recommended)\n"
+ " cmake .. for out-of-source build inside subfolder\n"
+ " cmake --help for more information\n"
+ "Note: Building in separate folder leaves source files intact."},
+ {0,0}
+};
+
#define CMAKE_BUILD_OPTIONS \
" <dir> = Project binary directory to be built.\n" \
" --target <tgt> = Build <tgt> instead of default targets.\n" \
@@ -223,6 +234,7 @@ int do_cmake(int ac, char const* const* av)
doc.SetName("cmake");
doc.SetSection("Name",cmDocumentationName);
doc.SetSection("Usage",cmDocumentationUsage);
+ doc.SetSection("Hint",cmDocumentationHint);
doc.AppendSection("Generators",generators);
doc.PrependSection("Options",cmDocumentationOptions);
--
1.8.5.2 (Apple Git-48)
0001-Produce-shorter-output-on-no-arguments-2.patch [^] (6,561 bytes) 2014-06-12 16:25 [Show Content] [Hide Content]From 9c442183e46ec153cdfc38d61c8b0cfeecd677be Mon Sep 17 00:00:00 2001
From: Adam Strzelecki <ono@java.pl>
Date: Thu, 12 Jun 2014 22:18:32 +0200
Subject: [PATCH] Produce shorter output on no arguments
Instead printing complete help cmake/ccmake now prints only Usage section and
extra information how to get more help or start your build.
Implementation Details:
Usage help type was renamed to Help, and new Usage was introduces that prints
only command line usage information without any extra details.
Commands add some extra information when no arguments are passed.
---
Source/CursesDialog/ccmake.cxx | 15 +++++++++++++++
Source/cmDocumentation.cxx | 20 +++++++++++++++++---
Source/cmDocumentation.h | 3 ++-
Source/cmDocumentationFormatter.h | 2 +-
Source/cmakemain.cxx | 15 +++++++++++++++
5 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index a9d4d98..cbbfeb8 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -42,6 +42,17 @@ static const char * cmDocumentationUsage[][2] =
};
//----------------------------------------------------------------------------
+static const char * cmDocumentationUsageNote[][2] =
+{
+ {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.\n"
+ "Run 'ccmake --help' for more information."},
+ {0,0}
+};
+
+//----------------------------------------------------------------------------
static const char * cmDocumentationOptions[][2] =
{
CMAKE_STANDARD_OPTIONS_TABLE,
@@ -102,6 +113,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;
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 8d035af..3ff1017 100644
--- a/Source/cmDocumentation.cxx
+++ b/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");
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index c98e48e..b72b5fe 100644
--- a/Source/cmDocumentation.h
+++ b/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;
diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h
index 61766b9..59513cc 100644
--- a/Source/cmDocumentationFormatter.h
+++ b/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
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 9f9f6bb..70b8d19 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -45,6 +45,17 @@ static const char * cmDocumentationUsage[][2] =
{0,0}
};
+//----------------------------------------------------------------------------
+static const char * cmDocumentationUsageNote[][2] =
+{
+ {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.\n"
+ "Run 'cmake --help' for more information."},
+ {0,0}
+};
+
#define CMAKE_BUILD_OPTIONS \
" <dir> = Project binary directory to be built.\n" \
" --target <tgt> = Build <tgt> instead of default targets.\n" \
@@ -223,6 +234,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);
--
1.8.5.2 (Apple Git-48)
|