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"
28PARAM_FLAG(
"verbose",
"Display informational messages and the full list of "
29 "parameters and timers at the end of execution.",
"v");
30PARAM_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."
static std::string ProgramName()
Get the program name as set by the BINDING_NAME() macro.
FunctionMapType functionMap
static IO & GetSingleton()
Retrieve the singleton.
static bool HasParam(const std::string &identifier)
See if the specified flag was found while parsing.
bool didParse
True, if IO was used to parse command line options.
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that IO knows about.
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 ].
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.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
PARAM_FLAG("help", "Default help info.", "h")
void PrintHelp(const std::string ¶m="")
Print the help for the given parameter.
PARAM_STRING_IN("info", "Print help on a specific option.", "", "")
void ParseCommandLine(int argc, char **argv)
Parse the command line, setting all of the options inside of the CLI object to their appropriate give...
std::string GetVersion()
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is...
Linear algebra utility functions, generally performed on matrices or vectors.
This structure holds all of the information about a single parameter, including its value (which is s...
std::string tname
Type information of this parameter.
bool required
True if this option is required.