[mlpack-svn] r16090 - mlpack/trunk/src/mlpack/core/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Dec 28 23:17:14 EST 2013
Author: rcurtin
Date: Sat Dec 28 23:17:14 2013
New Revision: 16090
Log:
Add information so a version can be obtained easily during runtime and also at
compile time.
Added:
mlpack/trunk/src/mlpack/core/util/version.hpp
Modified:
mlpack/trunk/src/mlpack/core/util/CMakeLists.txt
mlpack/trunk/src/mlpack/core/util/cli.cpp
mlpack/trunk/src/mlpack/core/util/cli.hpp
Modified: mlpack/trunk/src/mlpack/core/util/CMakeLists.txt
==============================================================================
--- mlpack/trunk/src/mlpack/core/util/CMakeLists.txt (original)
+++ mlpack/trunk/src/mlpack/core/util/CMakeLists.txt Sat Dec 28 23:17:14 2013
@@ -23,6 +23,7 @@
string_util.cpp
timers.hpp
timers.cpp
+ version.hpp
)
# add directory name to sources
Modified: mlpack/trunk/src/mlpack/core/util/cli.cpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.cpp (original)
+++ mlpack/trunk/src/mlpack/core/util/cli.cpp Sat Dec 28 23:17:14 2013
@@ -184,7 +184,15 @@
*/
void CLI::DefaultMessages()
{
- // Default help message
+ // --version is prioritized over --help.
+ if (HasParam("version"))
+ {
+ std::cout << GetSingleton().programName << ": part of "
+ << util::GetVersion() << std::endl;
+ exit(0);
+ }
+
+ // Default help message.
if (HasParam("help"))
{
Log::Info.ignoreInput = false;
@@ -371,6 +379,7 @@
{
Timer::Start("total_time");
+ GetSingleton().programName = std::string(line[0]);
po::variables_map& vmap = GetSingleton().vmap;
po::options_description& desc = GetSingleton().desc;
@@ -732,3 +741,4 @@
PARAM_STRING("info", "Get help on a specific module or option.", "", "");
PARAM_FLAG("verbose", "Display informational messages and the full list of "
"parameters and timers at the end of execution.", "v");
+PARAM_FLAG("version", "Display the version of mlpack.", "V");
Modified: mlpack/trunk/src/mlpack/core/util/cli.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/core/util/cli.hpp (original)
+++ mlpack/trunk/src/mlpack/core/util/cli.hpp Sat Dec 28 23:17:14 2013
@@ -19,6 +19,7 @@
#include "timers.hpp"
#include "cli_deleter.hpp" // To make sure we can delete the singleton.
+#include "version.hpp"
/**
* Document an executable. Only one instance of this macro should be
@@ -597,7 +598,7 @@
*
* In this case, the singleton is used to store data for the static methods,
* as there is no point in defining static methods only to have users call
- * private instance methods
+ * private instance methods.
*
* @return The singleton instance for use in the static methods.
*/
@@ -689,6 +690,9 @@
//! True, if CLI was used to parse command line options.
bool didParse;
+ //! Hold the name of the program for --version.
+ std::string programName;
+
//! Holds the timer objects.
Timers timer;
Added: mlpack/trunk/src/mlpack/core/util/version.hpp
==============================================================================
--- (empty file)
+++ mlpack/trunk/src/mlpack/core/util/version.hpp Sat Dec 28 23:17:14 2013
@@ -0,0 +1,25 @@
+/**
+ * @file version.hpp
+ * @author Ryan Curtin
+ *
+ * The current version of mlpack, available as macros and as a string.
+ */
+#ifndef __MLPACK_CORE_UTIL_VERSION_HPP
+#define __MLPACK_CORE_UTIL_VERSION_HPP
+
+// The version of mlpack. If this is svn trunk, this will be a version with
+// higher number than the most recent release.
+#define __MLPACK_VERSION_MAJOR 1
+#define __MLPACK_VERSION_MINOR 0
+#define __MLPACK_VERSION_PATCH 8
+
+// The name of the version (for use by --version).
+namespace mlpack {
+namespace util {
+
+inline std::string GetVersion() { return "mlpack trunk"; }
+
+}; // namespace util
+}; // namespace mlpack
+
+#endif
More information about the mlpack-svn
mailing list