This class wraps provides and tracks access to command line parameters. More...
#include <CommandLine.h>
Classes | |
struct | Option |
Public Types | |
using | ArgumentType = InputParameters::CommandLineMetadata::ArgumentType |
Public Member Functions | |
CommandLine () | |
CommandLine (int argc, char *argv[]) | |
CommandLine (const CommandLine &other) | |
virtual | ~CommandLine () |
void | addArguments (int argc, char *argv[]) |
void | addArgument (std::string) |
void | initForMultiApp (const std::string &) |
Removes multiapp parameters not associated with the supplied name. More... | |
const std::vector< std::string > & | getArguments () |
Return the raw argv arguments as a vector. More... | |
void | addCommandLineOptionsFromParams (const InputParameters ¶ms) |
void | populateInputParams (InputParameters ¶ms) |
void | addOption (const std::string &name, Option cli_opt) |
bool | search (const std::string &option_name) |
This routine searches the command line for the given option "handle" and returns a boolean indicating whether it was found. More... | |
template<typename T > | |
bool | search (const std::string &option_name, T &argument) |
template<typename T > | |
bool | search (const std::string &option_name, std::vector< T > &argument) |
std::vector< std::string >::const_iterator | find (const std::string &option_name) const |
Returns an iterator to the underlying argument vector to the position of the option or end if the option is not on the command line. More... | |
std::vector< std::string >::const_iterator | begin () const |
std::vector< std::string >::const_iterator | end () const |
std::string | getExecutableName () const |
Get the executable name. More... | |
std::string | getExecutableNameBase () const |
Get the exectuable name base (the name without the -[opt,oprof,devel,dbg]) More... | |
void | printUsage () const |
Print the usage info for this command line. More... | |
void | markHitParamUsed (int argi) |
void | markHitParam (int argi) |
std::set< int > | unused (const Parallel::Communicator &comm) |
Protected Member Functions | |
template<typename T > | |
void | setArgument (std::stringstream &stream, T &argument) |
Helper for setting the argument value, allows specialization. More... | |
template<typename T > | |
void | setArgument (std::stringstream &stream, T &argument, const std::string &cli_switch) |
Helper for setting the argument value; catches errors so we can provide more context. More... | |
template<> | |
void | setArgument (std::stringstream &stream, MooseEnum &argument) |
template<> | |
void | setArgument (std::stringstream &stream, MooseEnum &argument) |
Protected Attributes | |
std::map< std::string, Option > | _cli_options |
Command line options. More... | |
Private Attributes | |
std::set< int > | _used_hiti |
indices of CLI args that have been marked as used More... | |
std::set< int > | _hiti |
indices of CLI args that are HIT syntax parameters More... | |
std::vector< std::string > | _argv |
Storage for the raw argv. More... | |
std::vector< std::string > | _args |
This class wraps provides and tracks access to command line parameters.
Definition at line 33 of file CommandLine.h.
Definition at line 36 of file CommandLine.h.
CommandLine::CommandLine | ( | ) |
Definition at line 23 of file CommandLine.C.
CommandLine::CommandLine | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 25 of file CommandLine.C.
CommandLine::CommandLine | ( | const CommandLine & | other | ) |
Definition at line 27 of file CommandLine.C.
|
virtual |
Definition at line 64 of file CommandLine.C.
void CommandLine::addArgument | ( | std::string | arg | ) |
Definition at line 44 of file CommandLine.C.
Referenced by addArguments().
void CommandLine::addCommandLineOptionsFromParams | ( | const InputParameters & | params | ) |
Definition at line 116 of file CommandLine.C.
Definition at line 172 of file CommandLine.C.
Referenced by addCommandLineOptionsFromParams().
std::vector< std::string >::const_iterator CommandLine::begin | ( | ) | const |
Definition at line 200 of file CommandLine.C.
std::vector< std::string >::const_iterator CommandLine::end | ( | ) | const |
Definition at line 206 of file CommandLine.C.
std::vector< std::string >::const_iterator CommandLine::find | ( | const std::string & | option_name | ) | const |
Returns an iterator to the underlying argument vector to the position of the option or end if the option is not on the command line.
Definition at line 181 of file CommandLine.C.
|
inline |
Return the raw argv arguments as a vector.
Definition at line 71 of file CommandLine.h.
Referenced by Moose::PetscSupport::petscSetupOutput().
std::string CommandLine::getExecutableName | ( | ) | const |
Get the executable name.
Definition at line 233 of file CommandLine.C.
Referenced by getExecutableNameBase(), and printUsage().
std::string CommandLine::getExecutableNameBase | ( | ) | const |
Get the exectuable name base (the name without the -[opt,oprof,devel,dbg])
Definition at line 241 of file CommandLine.C.
void CommandLine::initForMultiApp | ( | const std::string & | subapp_full_name | ) |
Removes multiapp parameters not associated with the supplied name.
When a sub-application is created the CommandLine object from the master application is copied and supplied to the sub-app. This method cleans up the copy so it is ready to be used for a sub-application by removing parameters that are not associated with the provided sub-application name.
Definition at line 67 of file CommandLine.C.
Definition at line 123 of file CommandLine.h.
Definition at line 122 of file CommandLine.h.
void CommandLine::populateInputParams | ( | InputParameters & | params | ) |
Definition at line 134 of file CommandLine.C.
void CommandLine::printUsage | ( | ) | const |
Print the usage info for this command line.
Definition at line 251 of file CommandLine.C.
Referenced by search().
bool CommandLine::search | ( | const std::string & | option_name | ) |
This routine searches the command line for the given option "handle" and returns a boolean indicating whether it was found.
If the given option has an argument it is also filled in.
Definition at line 212 of file CommandLine.C.
Referenced by populateInputParams().
bool CommandLine::search | ( | const std::string & | option_name, |
T & | argument | ||
) |
Definition at line 215 of file CommandLine.h.
bool CommandLine::search | ( | const std::string & | option_name, |
std::vector< T > & | argument | ||
) |
Definition at line 260 of file CommandLine.h.
|
protected |
Helper for setting the argument value, allows specialization.
Definition at line 173 of file CommandLine.h.
Referenced by search(), and setArgument().
|
protected |
Helper for setting the argument value; catches errors so we can provide more context.
Definition at line 180 of file CommandLine.h.
|
protected |
|
protected |
Definition at line 285 of file CommandLine.C.
|
inline |
Definition at line 128 of file CommandLine.h.
|
private |
Definition at line 168 of file CommandLine.h.
Referenced by addArgument(), begin(), end(), find(), getExecutableName(), and search().
|
private |
Storage for the raw argv.
Definition at line 166 of file CommandLine.h.
Referenced by addArgument(), getArguments(), initForMultiApp(), and search().
|
protected |
Command line options.
Definition at line 156 of file CommandLine.h.
Referenced by addOption(), find(), printUsage(), and search().
|
private |
indices of CLI args that are HIT syntax parameters
Definition at line 163 of file CommandLine.h.
Referenced by initForMultiApp(), markHitParam(), and unused().
|
private |
indices of CLI args that have been marked as used
Definition at line 160 of file CommandLine.h.
Referenced by initForMultiApp(), markHitParamUsed(), and unused().