Go to the documentation of this file.
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");
43 std::map<std::string, util::ParamData>& parameters =
IO::Parameters();
44 using ItType = std::map<std::string, util::ParamData>::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<std::string>(
"info");
124 Log::Debug <<
"Compiled with debugging symbols." << std::endl;
133 for (std::map<std::string, util::ParamData>::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."
void PrintHelp(const std::string ¶m="")
Print the help for the given parameter.
static std::string ProgramName()
Get the program name as set by the BINDING_NAME() macro.
static MLPACK_EXPORT util::NullOutStream Debug
MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows com...
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that IO knows about.
bool didParse
True, if IO was used to parse command line options.
PARAM_STRING_IN("info", "Print help on a specific option.", "", "")
bool ignoreInput
Discards input, prints nothing if true.
This structure holds all of the information about a single parameter, including its value (which is s...
Linear algebra utility functions, generally performed on matrices or vectors.
std::string GetVersion()
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is...
FunctionMapType functionMap
static bool HasParam(const std::string &identifier)
See if the specified flag was found while parsing.
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
bool required
True if this option is required.
void ParseCommandLine(int argc, char **argv)
Parse the command line, setting all of the options inside of the CLI object to their appropriate give...
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
static IO & GetSingleton()
Retrieve the singleton.
std::string tname
Type information of this parameter.
PARAM_FLAG("help", "Default help info.", "h")