[mlpack-git] master: Don't print "Required options:" unless we need to. (3ae72c5)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Mon Dec 21 13:26:35 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/09cbc6e13aa3cb8a7c4ea6d2e1612977a40c6be7...be72510a765362f86782a8892f0e979aaa4a9f62
>---------------------------------------------------------------
commit 3ae72c567b7db7ed2b834bd2ec21ac44c48607dd
Author: ryan <ryan at ratml.org>
Date: Mon Dec 21 12:39:24 2015 -0500
Don't print "Required options:" unless we need to.
The same for "Options:", but I don't think there are any mlpack programs that
have only required options.
>---------------------------------------------------------------
3ae72c567b7db7ed2b834bd2ec21ac44c48607dd
src/mlpack/core/util/cli.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/mlpack/core/util/cli.cpp b/src/mlpack/core/util/cli.cpp
index 422d72d..c83698f 100644
--- a/src/mlpack/core/util/cli.cpp
+++ b/src/mlpack/core/util/cli.cpp
@@ -602,10 +602,7 @@ void CLI::PrintHelp(const std::string& param)
for (size_t pass = 0; pass < 2; ++pass)
{
- if (pass == 0)
- std::cout << "Required options:" << std::endl << std::endl;
- else
- std::cout << "Options: " << std::endl << std::endl;
+ bool printedHeader = false;
// Print out the descriptions of everything else.
for (iter = gmap.begin(); iter != gmap.end(); ++iter)
@@ -629,6 +626,15 @@ void CLI::PrintHelp(const std::string& param)
if ((pass == 1) && required)
continue; // Don't print this one.
+ if (!printedHeader)
+ {
+ printedHeader = true;
+ if (pass == 0)
+ std::cout << "Required options:" << std::endl << std::endl;
+ else
+ std::cout << "Options: " << std::endl << std::endl;
+ }
+
if (pass == 1) // Append default value to description.
{
desc += " Default value ";
More information about the mlpack-git
mailing list