13 #ifndef MLPACK_BINDINGS_CLI_PARSE_COMMAND_LINE_HPP 14 #define MLPACK_BINDINGS_CLI_PARSE_COMMAND_LINE_HPP 19 #include "third_party/CLI/CLI11.hpp" 28 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of " 29 "parameters and timers at the end of execution.",
"v");
30 PARAM_FLAG(
"version",
"Display the version of mlpack.",
"V");
44 using ItType = std::map
::iterator; 46 for (ItType it = parameters.begin(); it != parameters.end(); ++it)
62 app.parse(argc, argv);
64 catch (
const CLI::ArgumentMismatch& err)
66 Log::Fatal <<
"An option is defined multiple times: " 67 << app.exit(err) << std::endl;
69 catch (
const CLI::OptionNotFound& onf)
71 Log::Fatal <<
"Required option --" << app.exit(onf) <<
"!" << std::endl;
73 catch (
const CLI::ParseError& pe)
78 catch (std::exception& ex)
80 Log::Fatal <<
"Caught exception from parsing command line: " 81 << ex.what() << std::endl;
107 std::string str = IO::GetParam
("info"); 124 Log::Debug <<
"Compiled with debugging symbols." << std::endl;
133 for (std::map
::const_iterator iter = 134 parameters.begin(); iter != parameters.end(); ++iter)
143 cliName =
"--" + cliName;
145 if (!app.count(cliName))
147 Log::Fatal <<
"Required option " << cliName <<
" is undefined."
Linear algebra utility functions, generally performed on matrices or vectors.
static MLPACK_EXPORT util::NullOutStream Debug
MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows com...
bool ignoreInput
Discards input, prints nothing if true.
bool didParse
True, if IO was used to parse command line options.
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
void ParseCommandLine(int argc, char **argv)
Parse the command line, setting all of the options inside of the CLI object to their appropriate give...
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
std::string GetVersion()
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is...
This structure holds all of the information about a single parameter, including its value (which is s...
static IO & GetSingleton()
Retrieve the singleton.
std::string tname
Type information of this parameter.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
static bool HasParam(const std::string &identifier)
See if the specified flag was found while parsing.
bool required
True if this option is required.
void PrintHelp(const std::string ¶m="")
Print the help for the given parameter.
FunctionMapType functionMap
PARAM_FLAG("help", "Default help info.", "h")
PARAM_STRING_IN("info", "Print help on a specific option.", "", "")
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that IO knows about.
static std::string ProgramName()
Get the program name as set by the BINDING_NAME() macro.