8 #include <argos3/core/config.h>
16 m_eAction(ACTION_UNKNOWN),
17 m_pcInitLogStream(nullptr),
18 m_pcInitLogErrStream(nullptr) {
22 "display this usage information",
28 "display the current version and release",
34 "do not use colored output [OPTIONAL]",
37 AddArgument<std::string>(
40 "the experiment XML configuration file",
41 m_strExperimentConfigFile
43 AddArgument<std::string>(
46 "query the available plugins",
49 AddArgument<std::string>(
52 "output log to file [OPTIONAL]",
55 AddArgument<std::string>(
58 "output logerr to file [OPTIONAL]",
67 if(m_cLogFile.is_open()) {
71 if(m_cLogErrFile.is_open()) {
73 m_cLogErrFile.close();
84 if(m_bNonColoredLog) {
90 if(m_strLogFileName !=
"") {
92 m_cLogFile.open(m_strLogFileName.c_str(), std::ios::trunc | std::ios::out);
93 if(m_cLogFile.fail()) {
99 if(m_strLogErrFileName !=
"") {
101 m_cLogErrFile.open(m_strLogErrFileName.c_str(), std::ios::trunc | std::ios::out);
102 if(m_cLogErrFile.fail()) {
111 if(m_strExperimentConfigFile !=
"") ++nOptionsOn;
112 if(m_strQuery !=
"") ++nOptionsOn;
113 if(m_bHelpWanted) ++nOptionsOn;
114 if(m_bVersionWanted) ++nOptionsOn;
115 if(nOptionsOn == 0) {
119 THROW_ARGOSEXCEPTION(
"Options --help, --version, --config-file and --query are mutually exclusive.");
122 if(m_strExperimentConfigFile !=
"") {
126 if(m_strQuery !=
"") {
134 if(m_bVersionWanted) {
144 c_log <<
"Autonomous Robots Go Swarming (ARGoS) v" << ARGOS_VERSION <<
"-" << ARGOS_RELEASE << std::endl;
145 c_log <<
"Released under the terms of the MIT license." << std::endl;
147 c_log <<
"Usage: argos3 [OPTIONS]" << std::endl;
149 c_log <<
" -h | --help display this usage information" << std::endl;
150 c_log <<
" -v | --version display ARGoS version and release" << std::endl;
151 c_log <<
" -c FILE | --config-file FILE the experiment XML configuration file" << std::endl;
152 c_log <<
" -q QUERY | --query QUERY query the available plugins." << std::endl;
153 c_log <<
" -n | --no-color do not use colored output [OPTIONAL]" << std::endl;
154 c_log <<
" -l | --log-file FILE redirect LOG to FILE [OPTIONAL]" << std::endl;
155 c_log <<
" -e | --logerr-file FILE redirect LOGERR to FILE [OPTIONAL]" << std::endl << std::endl;
156 c_log <<
"The options --config-file and --query are mutually exclusive. Either you use" << std::endl;
157 c_log <<
"the first, and thus you run an experiment, or you use the second to query the" << std::endl;
158 c_log <<
"plugins." << std::endl << std::endl;
159 c_log <<
"EXAMPLES" << std::endl << std::endl;
160 c_log <<
"To run an experiment, type:" << std::endl << std::endl;
161 c_log <<
" argos3 -c /path/to/myconfig.argos" << std::endl << std::endl;
162 c_log <<
"To query the plugins, type:" << std::endl << std::endl;
163 c_log <<
" argos3 -q QUERY" << std::endl << std::endl;
164 c_log <<
"where QUERY can have the following values:" << std::endl << std::endl;
165 c_log <<
" all print a list of all the available plugins" << std::endl;
166 c_log <<
" actuators print a list of all the available actuators" << std::endl;
167 c_log <<
" sensors print a list of all the available sensors" << std::endl;
168 c_log <<
" physics_engines print a list of all the available physics engines" << std::endl;
169 c_log <<
" media print a list of all the available media" << std::endl;
170 c_log <<
" visualizations print a list of all the available visualizations" << std::endl;
171 c_log <<
" entities print a list of all the available entities" << std::endl << std::endl;
172 c_log <<
"Alternatively, QUERY can be the name of a specific plugin as returned by the" << std::endl;
173 c_log <<
"above commands. In this case, you get a complete description of the matching" << std::endl;
174 c_log <<
"plugins." << std::endl << std::endl;
181 LOG <<
"ARGOS_VERSION=" ARGOS_VERSION
"-" ARGOS_RELEASE << std::endl;
182 LOG <<
"ARGOS_INSTALL_PREFIX=" ARGOS_INSTALL_PREFIX << std::endl;
183 #ifdef ARGOS_USE_DOUBLE
184 LOG <<
"ARGOS_USE_DOUBLE=ON" << std::endl;
186 LOG <<
"ARGOS_USE_DOUBLE=OFF" << std::endl;
188 #ifdef ARGOS_WITH_LUA
189 LOG <<
"ARGOS_WITH_LUA=ON" << std::endl;
191 LOG <<
"ARGOS_WITH_LUA=OFF" << std::endl;
193 LOG <<
"ARGOS_BUILD_FLAGS=" ARGOS_BUILD_FLAGS << std::endl;
#define THROW_ARGOSEXCEPTION(message)
This macro throws an ARGoS exception with the passed message.
signed int SInt32
32-bit signed integer.
unsigned int UInt32
32-bit unsigned integer.
The namespace containing all the ARGoS related code.
CARGoSLog LOGERR(std::cerr, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_RED))
CARGoSLog LOG(std::cout, SLogColor(ARGOS_LOG_ATTRIBUTE_BRIGHT, ARGOS_LOG_COLOR_GREEN))
virtual void Parse(SInt32 n_argc, char **ppch_argv)
Parses the command line.
CARGoSCommandLineArgParser()
Class constructor.
virtual ~CARGoSCommandLineArgParser()
Class destructor.
virtual void PrintVersion()
Prints the current ARGoS version and release.
virtual void PrintUsage(CARGoSLog &c_log)
Prints usage information to the wanted log.
void AddFlag(char ch_short_option, const std::string &str_long_option, const std::string &str_description, bool &b_flag)
Adds a flag to the parser.
virtual void Parse(SInt32 n_argc, char **ppch_argv)
Parses the arguments on the command line.
std::ostream & GetStream()
void DisableColoredOutput()