mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
add --print-options
to print available options in short format
This commit is contained in:
parent
cae3fd6aa3
commit
1d38a2350f
|
@ -68,6 +68,18 @@ void FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregist
|
|||
}
|
||||
}
|
||||
|
||||
if (fVarMap.count("print-options"))
|
||||
{
|
||||
PrintOptionsRaw();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (fVarMap.count("id") == 0)
|
||||
{
|
||||
LOG(ERROR) << "Device id not provided, provide with --id";
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
string verbosity = GetValue<string>("verbosity");
|
||||
string logFile = GetValue<string>("log-to-file");
|
||||
bool color = GetValue<bool>("log-color");
|
||||
|
@ -183,7 +195,6 @@ void FairMQProgOptions::ParseAll(const int argc, char** argv, bool allowUnregist
|
|||
LOG(DEBUG) << "channel-config: Parsing channel configuration";
|
||||
UserParser<FairMQParser::SUBOPT>(fVarMap, id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FairProgOptions::PrintOptions();
|
||||
|
@ -312,7 +323,7 @@ void FairMQProgOptions::InitOptionDescription()
|
|||
;
|
||||
|
||||
fMQOptionsInCfg.add_options()
|
||||
("id", po::value<string>()->required(), "Device ID (required argument).")
|
||||
("id", po::value<string>(), "Device ID (required argument).")
|
||||
("io-threads", po::value<int >()->default_value(1), "Number of I/O threads.")
|
||||
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
|
||||
("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).")
|
||||
|
@ -331,7 +342,7 @@ void FairMQProgOptions::InitOptionDescription()
|
|||
else
|
||||
{
|
||||
fMQOptionsInCmd.add_options()
|
||||
("id", po::value<string>()->required(), "Device ID (required argument)")
|
||||
("id", po::value<string>(), "Device ID (required argument)")
|
||||
("io-threads", po::value<int >()->default_value(1), "Number of I/O threads")
|
||||
("transport", po::value<string>()->default_value("zeromq"), "Transport ('zeromq'/'nanomsg').")
|
||||
("config", po::value<string>()->default_value("static"), "Config source ('static'/<config library filename>).")
|
||||
|
|
|
@ -37,18 +37,9 @@ FairProgOptions::FairProgOptions() :
|
|||
fGenericDesc.add_options()
|
||||
("help,h", "produce help")
|
||||
("version,v", "print version")
|
||||
("verbosity", po::value<std::string>(&fVerbosityLevel)->default_value("DEBUG"), "Verbosity level : \n"
|
||||
" TRACE \n"
|
||||
" DEBUG \n"
|
||||
" RESULTS \n"
|
||||
" INFO \n"
|
||||
" WARN \n"
|
||||
" ERROR \n"
|
||||
" STATE \n"
|
||||
" NOLOG"
|
||||
)
|
||||
("verbosity", po::value<std::string>(&fVerbosityLevel)->default_value("DEBUG"), "Verbosity level : TRACE, DEBUG, RESULTS, INFO, WARN, ERROR, STATE, NOLOG")
|
||||
("log-color", po::value<bool>()->default_value(true), "logger color: true or false")
|
||||
;
|
||||
("print-options", po::value<bool>()->implicit_value(true), "print options in machine-readable format");
|
||||
|
||||
fSeverityMap["TRACE"] = FairMQ::severity_level::TRACE;
|
||||
fSeverityMap["DEBUG"] = FairMQ::severity_level::DEBUG;
|
||||
|
@ -241,6 +232,31 @@ int FairProgOptions::PrintHelp() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
int FairProgOptions::PrintOptionsRaw()
|
||||
{
|
||||
MapVarValInfo_t mapInfo;
|
||||
|
||||
for (const auto& m : fVarMap)
|
||||
{
|
||||
mapInfo[m.first] = GetVariableValueInfo(m.second);
|
||||
}
|
||||
|
||||
for (const auto& p : mapInfo)
|
||||
{
|
||||
string keyStr;
|
||||
string valueStr;
|
||||
string typeInfoStr;
|
||||
string defaultStr;
|
||||
string emptyStr;
|
||||
keyStr = p.first;
|
||||
tie(valueStr, typeInfoStr, defaultStr, emptyStr) = p.second;
|
||||
auto option = fCmdLineOptions.find_nothrow(keyStr, false);
|
||||
cout << keyStr << ":" << valueStr << ":" << typeInfoStr << ":" << (option ? option->description() : "<not found>") << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FairProgOptions::PrintOptions()
|
||||
{
|
||||
// //////////////////////////////////
|
||||
|
|
|
@ -135,6 +135,7 @@ class FairProgOptions
|
|||
virtual void ParseAll(const int argc, char** argv, bool allowUnregistered = false) = 0;// TODO change return type to bool and propagate to executable
|
||||
|
||||
virtual int PrintOptions();
|
||||
virtual int PrintOptionsRaw();
|
||||
int PrintHelp() const;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -205,6 +205,10 @@ struct ConvertVariableValue : T
|
|||
if (is_this_type<std::size_t>(varValue))
|
||||
return T::template Value<std::size_t>(varValue, std::string("<std::size_t>"), defaultedValue, emptyValue);
|
||||
|
||||
// uint64_t
|
||||
if (is_this_type<std::uint64_t>(varValue))
|
||||
return T::template Value<std::uint64_t>(varValue, std::string("<std::uint64_t>"), defaultedValue, emptyValue);
|
||||
|
||||
// std::vector size_t
|
||||
if (is_this_type<std::vector<std::size_t>>(varValue))
|
||||
return T::template Value<std::vector<std::size_t>>(varValue, std::string("<vector<std::size_t>>"), defaultedValue, emptyValue);
|
||||
|
|
Loading…
Reference in New Issue
Block a user