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" 36 const char* bindingName =
"")
49 std::map<std::string, util::ParamData>& parameters = params.
Parameters();
50 using ItType = std::map<std::string, util::ParamData>::iterator;
52 for (ItType it = parameters.begin(); it != parameters.end(); ++it)
64 app.parse(argc, argv);
66 catch (
const CLI::ArgumentMismatch& err)
68 Log::Fatal <<
"An option is defined multiple times: " 69 << app.exit(err) << std::endl;
71 catch (
const CLI::OptionNotFound& onf)
73 Log::Fatal <<
"Required option --" << app.exit(onf) <<
"!" << std::endl;
75 catch (
const CLI::ParseError& pe)
80 catch (std::exception& ex)
82 Log::Fatal <<
"Caught exception from parsing command line: " 83 << ex.what() << std::endl;
90 if (params.
Has(
"version"))
98 if (params.
Has(
"help"))
106 if (params.
Has(
"info"))
109 std::string str = params.
Get<std::string>(
"info");
126 Log::Debug <<
"Compiled with debugging symbols." << std::endl;
128 if (params.
Has(
"verbose"))
135 for (std::map<std::string, util::ParamData>::const_iterator iter =
136 parameters.begin(); iter != parameters.end(); ++iter)
145 cliName =
"--" + cliName;
147 if (!app.count(cliName))
149 Log::Fatal <<
"Required option " << cliName <<
" is undefined."
void PrintHelp(util::Params ¶ms, const std::string ¶m="")
Print the help for the given parameter.
mlpack::util::Params ParseCommandLine(int argc, char **argv, const char *bindingName="")
Parse the command line, setting all of the options inside of the CLI object to their appropriate give...
const BindingDetails & Doc() const
Get the binding details.
Linear algebra utility functions, generally performed on matrices or vectors.
static util::Params Parameters(const std::string &bindingName)
Return a new Params object initialized with all the parameters of the binding bindingName.
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.
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 ].
std::string GetVersion()
This will return either "mlpack x.y.z" or "mlpack master-XXXXXXX" depending on whether or not this is...
std::map< std::string, ParamData > & Parameters()
Get the map of parameters.
This structure holds all of the information about a single parameter, including its value (which is s...
T & Get(const std::string &identifier)
Get the value of type T found for the parameter specified by identifier.
bool Has(const std::string &identifier) const
Return true if the specified parameter was given.
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...
bool required
True if this option is required.
FunctionMapType functionMap
Map for functions and types.
std::string name
User-friendly name of the binding.
The Params class holds all information about the parameters passed to a specific binding.