14 #ifndef MLPACK_CORE_UTIL_CLI_HPP
15 #define MLPACK_CORE_UTIL_CLI_HPP
22 #include <boost/any.hpp>
23 #include <boost/program_options.hpp>
35 #define TYPENAME(x) (std::string(typeid(x).name()))
37 namespace po = boost::program_options;
209 static void Add(
const std::string& path,
210 const std::string& description,
211 const std::string& alias =
"",
212 const bool required =
false,
213 const bool input =
true);
228 static void Add(
const std::string& identifier,
229 const std::string& description,
230 const std::string& alias =
"",
231 const bool required =
false,
232 const bool input =
true);
241 static void AddFlag(
const std::string& identifier,
242 const std::string& description,
243 const std::string& alias =
"");
265 static T&
GetParam(
const std::string& identifier);
294 static bool HasParam(
const std::string& identifier);
303 static std::string
HyphenateString(
const std::string& str,
int padding);
333 static void PrintHelp(
const std::string& param =
"");
351 po::options_description desc;
354 po::variables_map vmap;
357 std::list<std::string> requiredOptions;
360 std::list<std::string> inputOptions;
362 std::list<std::string> outputOptions;
365 typedef std::map<std::string, ParamData> gmap_t;
369 typedef std::map<std::string, std::string> amap_t;
373 static CLI* singleton;
379 std::string programName;
398 static void AddAlias(
const std::string& alias,
const std::string& original);
407 static std::string AliasReverseLookup(
const std::string& value);
414 static void RequiredOptions();
419 static void UpdateGmap();
431 CLI(
const std::string& optionsName);
438 struct IsStdVector {
const static bool value =
false; };
441 template<
typename eT>
442 struct IsStdVector<std::vector<eT>> {
const static bool value =
true; };
456 const typename boost::disable_if<IsStdVector<T>>::type* = 0);
470 const typename boost::enable_if<IsStdVector<T>>::type* = 0);
476 #include "cli_impl.hpp"
static CLI & GetSingleton()
Retrieve the singleton.
static void RegisterProgramDoc(util::ProgramDoc *doc)
Registers a ProgramDoc object, which contains documentation about the program.
static void PrintHelp(const std::string ¶m="")
Print out the help info of the hierarchy.
The core includes that mlpack expects; standard C++ includes and Armadillo.
bool isFlag
True if the wasPassed value should not be ignored.
static std::string GetDescription(const std::string &identifier)
Get the description of the specified node.
bool wasPassed
True if this parameter was passed in via command line or file.
std::string name
Name of this parameter.
The timer class provides a way for mlpack methods to be timed.
static void Print()
Print out the current hierarchy.
static void RemoveDuplicateFlags(po::basic_parsed_options< char > &bpo)
Removes duplicate flags.
static void Destroy()
Destroy the CLI object.
util::ProgramDoc * doc
Pointer to the ProgramDoc object.
std::string tname
Type information of this parameter.
static T & GetParam(const std::string &identifier)
Grab the value of type T found while parsing.
Aids in the extensibility of CLI by focusing potential changes into one structure.
static void PrintOutput()
Print the value of any output options on stdout.
static void DefaultMessages()
Parses the parameters for 'help' and 'info'.
static std::string HyphenateString(const std::string &str, int padding)
Hyphenate a string or split it onto multiple 80-character lines, with some amount of padding on each ...
static void Add(const std::string &path, const std::string &description, const std::string &alias="", const bool required=false, const bool input=true)
Adds a parameter to the hierarchy; use the PARAM_*() macros instead of this (i.e. ...
static void AddFlag(const std::string &identifier, const std::string &description, const std::string &alias="")
Adds a flag parameter to the hierarchy; use PARAM_FLAG() instead of this.
A static object whose constructor registers program documentation with the CLI class.
std::string desc
Description of this parameter, if any.
Parses the command line for parameters and holds user-specified parameters.
static void ParseCommandLine(int argc, char **argv)
Parses the commandline for arguments.
boost::any value
The actual value of this parameter.
static bool HasParam(const std::string &identifier)
See if the specified flag was found while parsing.