|
DAS
3.0
Das Analysis System
|
Common class to interpret the command line, based on Boost Program Options.
Options may also be partly provided via a configuration file. Additional options to split the input file are also possible. Minimal working example:
options.arg<
int>(
"myArg",
"correction.here",
"my description");
options.args(
"allOtherArgs",
"correction.there.list",
"garbage collector");
where the config is a Boost Property Tree. A one-liner is even possible:
auto const&
config =
DT::Options(
"Global description.",
DT::config |
DT::split).
input(
"input", &
input,
"input ROOT file").
output(
"output", &
output,
"output ROOT file").
arg<
int>(
"myArg",
"correction.here",
"my description").
args(
"allOtherArgs",
"correction.there.list",
"garbage collector")(argc, argv);
The order matters only for the positional options, where input(s) should be given first, then output(s), then additional positional options. The position of explicit options (e.g. -v
) does not matter. Options::args
may be used as a garbage collector for extra positional options.
#include <Options.h>
|
| Options (const std::string &, int=none, const char *commit=DARWIN_GIT_COMMIT, const char *example=DARWIN_EXAMPLE) |
|
| Options ()=delete |
|
Options & | input (const char *, std::filesystem::path *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
Options & | inputs (const char *, std::vector< std::filesystem::path > *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
Options & | output (const char *, std::filesystem::path *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
template<typename T > |
Options & | arg (const char *name, const char *configpath, const char *desc) |
|
Options & | args (const char *name, const char *configpath, const char *desc) |
|
const boost::property_tree::ptree & | operator() (int, const char *const []) |
|
auto | commit () const |
|
int | steering () const |
|
std::pair< unsigned, unsigned > | slice () const |
|
| Options (const std::string &, int=none, const char *commit=DARWIN_GIT_COMMIT, const char *example=DARWIN_EXAMPLE) |
|
| Options ()=delete |
|
Options & | input (const char *, std::filesystem::path *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
Options & | inputs (const char *, std::vector< std::filesystem::path > *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
Options & | output (const char *, std::filesystem::path *, const char *, const std::vector< std::string > &={".root", ".xml"}) |
|
template<typename T > |
Options & | arg (const char *name, const char *configpath, const char *desc) |
|
Options & | args (const char *name, const char *configpath, const char *desc) |
|
const boost::property_tree::ptree & | operator() (int, const char *const []) |
|
auto | commit () const |
|
int | steering () const |
|
std::pair< unsigned, unsigned > | slice () const |
|
|
enum | Stage {
Input,
Output,
Arg,
Args,
Input,
Output,
Arg,
Args
} |
|
enum | Stage {
Input,
Output,
Arg,
Args,
Input,
Output,
Arg,
Args
} |
|
|
void | parse_helper (int, const char *const []) |
|
void | parse_common (int, const char *const []) |
|
void | parse_custom (int, const char *const []) |
|
Options & | set (const char *, const boost::program_options::value_semantic *, const char *) |
|
template<typename T > |
std::function< void(T)> | put (const std::string &configpath) |
|
bool | allow_unregistered () const |
|
std::string | exec (const std::string &) |
|
void | parse_helper (int, const char *const []) |
|
void | parse_common (int, const char *const []) |
|
void | parse_custom (int, const char *const []) |
|
Options & | set (const char *, const boost::program_options::value_semantic *, const char *) |
|
template<typename T > |
std::function< void(T)> | put (const std::string &configpath) |
|
bool | allow_unregistered () const |
|
std::string | exec (const std::string &) |
|
|
static std::filesystem::path | prefix |
|
◆ Stage [1/2]
Enumerator |
---|
Input | first the inputs
|
Output | then the outputs (inputs are no longer allowed)
|
Arg | then the registered arguments (inputs and outputs no longer allowed)
|
Args | finally the remaining arguments / garbage collector (must be very last)
|
Input | first the inputs
|
Output | then the outputs (inputs are no longer allowed)
|
Arg | then the registered arguments (inputs and outputs no longer allowed)
|
Args | finally the remaining arguments / garbage collector (must be very last)
|
◆ Stage [2/2]
Enumerator |
---|
Input | first the inputs
|
Output | then the outputs (inputs are no longer allowed)
|
Arg | then the registered arguments (inputs and outputs no longer allowed)
|
Args | finally the remaining arguments / garbage collector (must be very last)
|
Input | first the inputs
|
Output | then the outputs (inputs are no longer allowed)
|
Arg | then the registered arguments (inputs and outputs no longer allowed)
|
Args | finally the remaining arguments / garbage collector (must be very last)
|
◆ Options() [1/4]
Constructor:
- contains a parser for the help itself
- contains a parser for the options, like config file and verbosity
- and contains a parser for the input, output, and any other option as positional arguments
- Parameters
-
tuto | description, to be displayed in the helper |
pars | flags for explicit, generic command options (see enum) |
commit | git commit for --git |
example | path to example |
109 (
"prefix,p", po::value<fs::path>(&
prefix),
"Prefix command, `parallel` or `submit` (for history only)");
113 (
"help,h",
"Help screen (what you are seeing right now)")
114 (
"tutorial,t",
"Brief description of the command's purpose")
115 (
"git,g",
"Commit hash of this executable at compilation time")
116 (
"input_ext,i",
"Expected extension for input(s) (one line for each input)")
117 (
"output_ext,o",
"Expected extension for output(s) (one line for each output)");
119 (
"example,e",
"Print config example");
123 (
"verbose,v", po::bool_switch()->default_value(
false),
124 "Enable debug mode (typically in slow operations such as the event loop)")
125 (
"mute,m", po::bool_switch()->default_value(
false)->notifier(
set_mute),
126 "Disable standard output stream");
129 "Configuration file in INFO, JSON, or XML format");
131 (
"nSplit,j", po::value<int>(&
j)->default_value(
j),
"Number of slices")
132 (
"nNow,k" , po::value<int>(&
k)->default_value(
k),
"Index of current slice");
134 (
"fill,f", po::bool_switch()->default_value(
false),
"Enable `TTree::Fill()`");
136 (
"Friend,F", po::bool_switch()->default_value(
false),
137 "Use `TTree` friends instead of cloning the whole input `TTree`");
139 (
"syst,s", po::bool_switch()->default_value(
false),
140 "Enable systematic variations");
◆ Options() [2/4]
No default constructor is allowed.
◆ Options() [3/4]
Constructor:
- contains a parser for the help itself
- contains a parser for the options, like config file and verbosity
- and contains a parser for the input, output, and any other option as positional arguments
- Parameters
-
commit | git commit for --git |
example | path to example |
◆ Options() [4/4]
No default constructor is allowed.
◆ allow_unregistered() [1/2]
bool allow_unregistered |
( |
| ) |
const |
|
inlineprivate |
◆ allow_unregistered() [2/2]
bool allow_unregistered |
( |
| ) |
const |
|
inlineprivate |
◆ arg() [1/2]
Options& arg |
( |
const char * |
name, |
|
|
const char * |
configpath, |
|
|
const char * |
desc |
|
) |
| |
|
inline |
Member to add an argument. It can be called several times in a row. Each argument may be provided via the configuration file too.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
name | name of the option, will be shown in helper |
configpath | path in config |
desc | description, shown in helper too |
227 if (
stage > Stage::Arg)
228 BOOST_THROW_EXCEPTION(std::runtime_error(
229 "Not possible to add another argument at this stage"));
234 const boost::program_options::value_semantic * s =
235 boost::program_options::value<T>()->notifier(put<T>(configpath));
◆ arg() [2/2]
Options& arg |
( |
const char * |
name, |
|
|
const char * |
configpath, |
|
|
const char * |
desc |
|
) |
| |
|
inline |
Member to add an argument. It can be called several times in a row. Each argument may be provided via the configuration file too.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
name | name of the option, will be shown in helper |
configpath | path in config |
desc | description, shown in helper too |
227 if (
stage > Stage::Arg)
228 BOOST_THROW_EXCEPTION(std::runtime_error(
229 "Not possible to add another argument at this stage"));
234 const boost::program_options::value_semantic * s =
235 boost::program_options::value<T>()->notifier(put<T>(configpath));
◆ args() [1/2]
Options& args |
( |
const char * |
name, |
|
|
const char * |
configpath, |
|
|
const char * |
desc |
|
) |
| |
Member to collect any addition arguments provided in command line. It should be called maximum once. The additional options will be collected as a list of strings.
- Parameters
-
name | generic name for unregistered options |
configpath | path in config. |
desc | description, shown in helper too |
◆ args() [2/2]
Options & args |
( |
const char * |
name, |
|
|
const char * |
configpath, |
|
|
const char * |
desc |
|
) |
| |
Member to collect any addition arguments provided in command line. It should be called maximum once. The additional options will be collected as a list of strings.
- Parameters
-
name | generic name for unregistered options |
configpath | path in config. |
desc | description, shown in helper too |
539 if (
stage >= Stage::Args)
540 BOOST_THROW_EXCEPTION(runtime_error(
"Only one garbage collector is possible"));
547 const po::value_semantic * s =
548 po::value<vector<string>>()->multitoken()->zero_tokens();
◆ check_input() [1/2]
void check_input |
( |
const std::filesystem::path & |
input | ) |
|
|
staticprivate |
Function used by Boost Program Options to check if the file does exist, and if yes, if it is readable and readable.
- Parameters
-
39 if (!fs::exists(
input))
40 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Bad input",
input,
41 make_error_code(errc::no_such_file_or_directory)));
46 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Input exists but cannot be read",
47 input, make_error_code(errc::permission_denied)));
◆ check_input() [2/2]
static void check_input |
( |
const std::filesystem::path & |
| ) |
|
|
staticprivate |
Function used by Boost Program Options to check if the file does exist, and if yes, if it is readable and readable.
◆ check_output() [1/2]
void check_output |
( |
const std::filesystem::path & |
output | ) |
|
|
staticprivate |
Function used by Boost Program Options to check if the file may already exist, and if yes, then if it is writable, and not a directory. (At this stage, the automatic naming of the output according to the name of the input should not happen. Such a thing should rather be done in the executable directly.)
- Parameters
-
52 fs::path outputHist =
output;
53 if (!
prefix.empty() && !fs::is_directory(
output)) outputHist.remove_filename();
54 full_cmd +=
' ' + outputHist.string();
56 if (!fs::exists(
output))
return;
58 if ((fs::status(
output).permissions() & fs::perms::owner_write)
61 BOOST_THROW_EXCEPTION(fs::filesystem_error(
62 "Output already exists and cannot be overwritten",
63 output, make_error_code(errc::permission_denied)));
66 if (fs::is_directory(
output) && fs::equivalent(
output,
".")) {
68 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Not a valid output",
69 output, make_error_code(errc::invalid_argument)));
71 else if (
output !=
"/dev/null")
◆ check_output() [2/2]
static void check_output |
( |
const std::filesystem::path & |
| ) |
|
|
staticprivate |
Function used by Boost Program Options to check if the file may already exist, and if yes, then if it is writable, and not a directory. (At this stage, the automatic naming of the output according to the name of the input should not happen. Such a thing should rather be done in the executable directly.)
◆ commit() [1/2]
◆ commit() [2/2]
◆ exec() [1/2]
std::string exec |
( |
const std::string & |
cmd | ) |
|
|
private |
- Returns
- output from command given to shell
- Parameters
-
cmd | cmd to run in the shell |
467 FILE * pipe = popen(
cmd.c_str(),
"r");
469 if (fgets(buffer, 128, pipe) != NULL)
◆ exec() [2/2]
std::string exec |
( |
const std::string & |
| ) |
|
|
private |
- Returns
- output from command given to shell
◆ input() [1/2]
Options& input |
( |
const char * |
, |
|
|
std::filesystem::path * |
, |
|
|
const char * |
, |
|
|
const std::vector< std::string > & |
= {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an input. It can be called several times in a row. This option should always be provided from the command line, and never via the config file.
- Returns
- the object itself, so that the arguments can be given in a row.
◆ input() [2/2]
Options & input |
( |
const char * |
name, |
|
|
std::filesystem::path * |
file, |
|
|
const char * |
desc, |
|
|
const std::vector< std::string > & |
ext = {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an input. It can be called several times in a row. This option should always be provided from the command line, and never via the config file.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
name | name of the option, will be shown in helper |
file | path pointer to file |
desc | description, shown in helper too |
452 if (
stage > Stage::Input)
453 BOOST_THROW_EXCEPTION(runtime_error(
454 "Not possible to add another input at this stage"));
457 const po::value_semantic * s =
458 po::value<fs::path>(file)->notifier(
check_input)->required();
◆ inputs() [1/2]
Options& inputs |
( |
const char * |
, |
|
|
std::vector< std::filesystem::path > * |
, |
|
|
const char * |
, |
|
|
const std::vector< std::string > & |
= {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an undefined amount of input. It can be called only once. This option should always be provided from the command line, and never via the config file. There can be no garbage collector in addition.
- Returns
- the object itself, so that the arguments can be given in a row.
◆ inputs() [2/2]
Options & inputs |
( |
const char * |
name, |
|
|
std::vector< std::filesystem::path > * |
files, |
|
|
const char * |
desc, |
|
|
const std::vector< std::string > & |
ext = {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an undefined amount of input. It can be called only once. This option should always be provided from the command line, and never via the config file. There can be no garbage collector in addition.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
name | name of the options, will be shown in helper |
files | paths to files |
desc | description, shown in helper too |
480 if (
stage > Stage::Input)
481 BOOST_THROW_EXCEPTION(runtime_error(
482 "Not possible to add another input at this stage"));
484 auto store = [
files,
this](
const string& pathRegex) {
486 const string& ls =
exec(
"ls -1d " + pathRegex);
488 vector<fs::path>
paths;
490 for (fs::path
const&
p:
paths) {
491 if (!fs::exists(
p))
continue;
495 if (
files->empty()) {
496 fs::path
p = pathRegex;
498 BOOST_THROW_EXCEPTION(
499 fs::filesystem_error(
"No input file could be found",
p,
500 make_error_code(errc::no_such_file_or_directory)));
505 return inputs + fs::canonical(input).string() +
' '; });
507 if (
files->size() > 1)
513 const po::value_semantic * s =
514 po::value<string>()->notifier(store)->required();
515 string full_desc = desc;
516 full_desc +=
" (use a regular expression, surrounded by quotation marks)";
517 return set(
name, s, full_desc.c_str());
◆ operator()() [1/2]
const boost::property_tree::ptree& operator() |
( |
int |
, |
|
|
const char * const |
[] |
|
) |
| |
Unique parser accessible by the user of the class. It should be directly given argc
and argv
from the main function.
◆ operator()() [2/2]
const boost::property_tree::ptree & operator() |
( |
int |
argc, |
|
|
const char * const |
argv[] |
|
) |
| |
Unique parser accessible by the user of the class. It should be directly given argc
and argv
from the main function.
429 catch (
const po::error& e) {
430 BOOST_THROW_EXCEPTION(po::error(e.what()));
◆ output() [1/2]
Options& output |
( |
const char * |
, |
|
|
std::filesystem::path * |
, |
|
|
const char * |
, |
|
|
const std::vector< std::string > & |
= {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an output. It can be called several times in a row. This option should always be provided from the command line, and never via the config file.
- Returns
- the object itself, so that the arguments can be given in a row.
◆ output() [2/2]
Options & output |
( |
const char * |
name, |
|
|
std::filesystem::path * |
file, |
|
|
const char * |
desc, |
|
|
const std::vector< std::string > & |
ext = {".root", ".xml"} |
|
) |
| |
expected file extension
Member to add an output. It can be called several times in a row. This option should always be provided from the command line, and never via the config file.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
name | name of the option, will be shown in helper |
file | path pointer to file |
desc | description, shown in helper too |
523 if (
stage > Stage::Output) {
525 BOOST_THROW_EXCEPTION(runtime_error(
526 "Not possible to add another output at this stage"));
528 stage = Stage::Output;
531 const po::value_semantic * s =
532 po::value<fs::path>(file)->notifier(
check_output)->required();
◆ parse_common() [1/2]
void parse_common |
( |
int |
argc, |
|
|
const char * const |
argv[] |
|
) |
| |
|
private |
Parser for generic options, such as the config (with -c
) or slices. It should be directly given argc
and argv
from the main function.
270 po::options_description cmd_line;
274 po::command_line_parser
parser{argc, argv};
276 .allow_unregistered();
278 po::variables_map vm;
279 po::store(
parser.run(), vm);
282 if (vm.count(
"nSplit")) {
283 auto j = vm[
"nSplit"].as<
int>();
285 BOOST_THROW_EXCEPTION(
286 invalid_argument(
"The number of slices must be larger than 0") );
288 if (vm.count(
"nNow")) {
289 auto k = vm[
"nNow"].as<
int>();
291 BOOST_THROW_EXCEPTION(
292 invalid_argument(
"The slice index must be smaller than the "
293 "number of slices.") );
297 if (vm.count(
"config")) {
301 else if (ext ==
".xml" ) {
304 pt_conf = userinfo.get_child(
"userinfo");
306 else BOOST_THROW_EXCEPTION(
307 fs::filesystem_error(
"Extension should be .json, .xml, or .info",
308 config_file, make_error_code(errc::invalid_argument)));
◆ parse_common() [2/2]
void parse_common |
( |
int |
, |
|
|
const char * const |
[] |
|
) |
| |
|
private |
Parser for generic options, such as the config (with -c
) or slices. It should be directly given argc
and argv
from the main function.
◆ parse_config() [1/2]
static void parse_config |
( |
boost::property_tree::ptree & |
, |
|
|
std::string |
= "" |
|
) |
| |
|
static |
Parse config if given. This method calls itself to parse the tree structure.
key in config (for recursive call)
◆ parse_config() [2/2]
static void parse_config |
( |
boost::property_tree::ptree & |
, |
|
|
std::string |
= "" |
|
) |
| |
|
static |
Parse config if given. This method calls itself to parse the tree structure.
key in config (for recursive call)
◆ parse_custom() [1/2]
void parse_custom |
( |
int |
, |
|
|
const char * const |
[] |
|
) |
| |
|
private |
Parser for options provided with args()
, defined differently in each application. It should be directly given argc
and argv
from the main function.
◆ parse_custom() [2/2]
void parse_custom |
( |
int |
argc, |
|
|
const char * const |
argv[] |
|
) |
| |
|
private |
Parser for options provided with args()
, defined differently in each application. It should be directly given argc
and argv
from the main function.
321 po::options_description cmd_line;
326 po::command_line_parser
parser{argc, argv};
330 po::variables_map vm;
331 po::parsed_options parsed =
parser.run();
332 po::store(parsed, vm);
337 if (vm.count(
name))
continue;
338 throw po::required_option(
name);
350 auto arg =
pt_conf.get_optional<
string>(configpath);
352 al::erase_all(*
arg,
"\n");
353 al::erase_all(*
arg,
" ");
354 al::erase_all(*
arg,
"\"");
355 if (
arg->empty())
continue;
362 if (!
pt_conf.count(configpath))
363 pt_conf.add<
string>(configpath,
"");
364 auto& subtree =
pt_conf.get_child(configpath);
366 for (
auto& item: subtree) {
367 string key = item.first,
368 value = item.second.get_value<
string>();
369 if (
key.empty() ||
key ==
"item")
371 else if (value.empty())
375 vector<string> items = po::collect_unrecognized(parsed.options,
376 po::include_positional);
379 items.erase(items.begin(), items.begin() + *
registered);
381 for (
auto& item: items) {
382 if (subtree.count(item))
continue;
383 subtree.add<
string>(item,
"");
◆ parse_env_var() [1/6]
static std::string parse_env_var |
( |
const char * |
p | ) |
|
|
inlinestatic |
Parse environment variable in C-style string.
◆ parse_env_var() [2/6]
static std::string parse_env_var |
( |
const char * |
p | ) |
|
|
inlinestatic |
Parse environment variable in C-style string.
◆ parse_env_var() [3/6]
static std::filesystem::path parse_env_var |
( |
const std::filesystem::path & |
p | ) |
|
|
inlinestatic |
Parse environment variable in a path.
◆ parse_env_var() [4/6]
static std::filesystem::path parse_env_var |
( |
const std::filesystem::path & |
p | ) |
|
|
inlinestatic |
Parse environment variable in a path.
◆ parse_env_var() [5/6]
string parse_env_var |
( |
std::string |
s | ) |
|
|
static |
◆ parse_env_var() [6/6]
static std::string parse_env_var |
( |
std::string |
| ) |
|
|
static |
◆ parse_helper() [1/2]
void parse_helper |
( |
int |
, |
|
|
const char * const |
[] |
|
) |
| |
|
private |
First parser that is called. As soon as -h
is given, or if the command is run without options, then the helper is shown. It should be directly given argc
and argv
from the main function.
◆ parse_helper() [2/2]
void parse_helper |
( |
int |
argc, |
|
|
const char * const |
argv[] |
|
) |
| |
|
private |
First parser that is called. As soon as -h
is given, or if the command is run without options, then the helper is shown. It should be directly given argc
and argv
from the main function.
185 po::command_line_parser
parser{argc, argv};
187 .allow_unregistered();
190 po::variables_map vm;
191 po::store(
parser.run(), vm);
194 if (vm.count(
"help") || argc == 1) {
195 fs::path executable = argv[0];
198 for (
const auto& option:
custom.options())
199 cout <<
'\t' << option->long_name()
200 <<
" = " << option->description() <<
'\n';
203 if (vm.count(
"help")) {
204 po::options_description cmd_line;
208 cout << cmd_line << endl;
211 if (vm.count(
"tutorial"))
214 "unless stated otherwise, all options except the input and output files "
215 "may be given either from the command line or from such a config. Unused "
216 "options in the config are simply ignored. The `flags` should be set at "
217 "the creation of the n-tuples; the `corrections` should be added step "
218 "by step (typically a couple of corrections per executable at most). How "
219 "the config is parsed may change from executable to executable. This "
220 "example uses the Boost INFO format, but JSON and XML formats are also "
221 "possible. It is possible to extract such a config from an existing ROOT "
222 "file by using `getMetaInfo`. Arguments from command line overwrite "
223 "arguments from the config.") << endl;
228 if (vm.count(
"example")) {
230 BOOST_THROW_EXCEPTION(
231 fs::filesystem_error(
"The example could not be found",
232 example, make_error_code(errc::no_such_file_or_directory)));
235 pt::ptree reduced_config;
238 reduced_config.add<
string>(
key, value);
242 write_info(ss, reduced_config);
243 string str = ss.str();
244 al::erase_all(str,
"\"\"");
245 cout << str << flush;
248 auto space_separate = [](
const string& a,
const string& b) {
252 if (vm.count(
"input_ext"))
253 for (
const vector<string>& ext:
inputExt)
255 cout << accumulate(next(begin(ext)), end(ext),
256 ext.front(), space_separate) << endl;
258 if (vm.count(
"output_ext"))
259 for (
const vector<string>& ext:
outputExt)
261 cout << accumulate(next(begin(ext)), end(ext),
262 ext.front(), space_separate) << endl;
264 if (!vm.empty() || argc == 1)
◆ put() [1/2]
std::function<void(T)> put |
( |
const std::string & |
configpath | ) |
|
|
inlineprivate |
Helper to call boost::property_tree::put
in Darwin::Toos::Options::args
.
- Returns
true
if Options::registered
has been initialised.
- Parameters
-
configpath | path in config file |
132 return [configpath,
this](T value) {
pt_conf.put<T>(configpath, value); };
◆ put() [2/2]
std::function<void(T)> put |
( |
const std::string & |
configpath | ) |
|
|
inlineprivate |
Helper to call boost::property_tree::put
in Darwin::Toos::Options::args
.
- Returns
true
if Options::registered
has been initialised.
- Parameters
-
configpath | path in config file |
132 return [configpath,
this](T value) {
pt_conf.put<T>(configpath, value); };
◆ set() [1/2]
Options& set |
( |
const char * |
, |
|
|
const boost::program_options::value_semantic * |
, |
|
|
const char * |
|
|
) |
| |
|
private |
◆ set() [2/2]
Options & set |
( |
const char * |
name, |
|
|
const boost::program_options::value_semantic * |
s, |
|
|
const char * |
desc |
|
) |
| |
|
private |
Generic code to add options. It is called internally by Options::input()
, Options::output()
, and Options::args()
.
- Returns
- the object itself, so that the arguments can be given in a row.
- Parameters
-
440 BOOST_THROW_EXCEPTION(invalid_argument(
441 "Once `Options::args()` has been called, "
442 "it is no longer possible to add any further options."));
◆ slice() [1/2]
std::pair<unsigned, unsigned> slice |
( |
| ) |
const |
|
inline |
Compactify slice information into a pair.
293 BOOST_THROW_EXCEPTION(invalid_argument(
"No splitting of the input file."));
294 return make_pair(
j,
k);
◆ slice() [2/2]
std::pair<unsigned, unsigned> slice |
( |
| ) |
const |
|
inline |
Compactify slice information into a pair.
293 BOOST_THROW_EXCEPTION(invalid_argument(
"No splitting of the input file."));
294 return make_pair(
j,
k);
◆ steering() [1/2]
Steering information for running of executable.
◆ steering() [2/2]
Steering information for running of executable.
◆ common
boost::program_options::options_description common |
|
private |
generic + explicit options like --verbose
◆ config_file
std::filesystem::path config_file |
|
private |
path to INFO, JSON, or XML config file
◆ configpaths
std::vector< std::string > configpaths |
|
private |
path to the options in config (except for I/O)
◆ custom
boost::program_options::options_description custom |
|
private |
for positional arguments, depending on the actual command
◆ example
const std::filesystem::path example |
|
private |
◆ full_cmd
static std::string full_cmd |
|
static |
extended version of the command for reproducibility
◆ helper
boost::program_options::options_description helper |
|
private |
◆ hidden
boost::program_options::options_description hidden |
|
private |
hidden interface (not for lambda user)
◆ inputExt
std::vector< std::vector< std::string > > inputExt |
|
private |
expected extensions of input files
◆ m_commit
const std::string m_commit |
|
private |
◆ names
std::vector< std::string > names |
|
private |
names of the different options (shown in synopsis
)
◆ outputExt
std::vector< std::vector< std::string > > outputExt |
|
private |
expected extensions of output files
◆ params
input parameters to interpret explicit options
◆ pos_hide
boost::program_options::positional_options_description pos_hide |
|
private |
parser for positional arguments
◆ prefix
static std::filesystem::path prefix |
|
staticprivate |
prefix command to steer -j
and -k
◆ pt_conf
boost::property_tree::ptree pt_conf |
|
private |
internal config obtained from arugments and input config
◆ registered
std::optional< unsigned > registered |
|
private |
collect the number of registered options (only if Options::args
has been called before)
◆ stage
◆ steer
output parameters for code executation
◆ synopsis
stores a clean version of the command, displayed w. -h
◆ tutorial
const std::string tutorial |
|
private |
define in constructor, shown with option -t
The documentation for this class was generated from the following files:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Darwin/interface/Options.h
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Darwin/src/Options.cc
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
cerr
Definition: Ntupliser_cfg.py:93
options
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:41
static const char * def
Definition: Step.h:36
paths
Definition: Ntupliser_cfg.py:296
p
Definition: Ntupliser_cfg.py:358
string key
Definition: jercExample.py:109
files
Definition: compareFiles.py:125
static const char * red
Definition: Step.h:34
cmd
Definition: Core-cfgcmd.txt:1
config
Definition: Ntupliser_cfg.py:260
static const char * orange
Definition: colours.h:6
string wrap_paragraph(const string &text)
Definition: Options.cc:149
#define DARWIN_VERSION
Definition: version.h:1
parser
Definition: compareFiles.py:118
Darwin::Tools::Options Options(const char *, int=Darwin::Tools::none)
Constructs Darwin options with the correct commit information.
Definition: DASOptions.cc:14
DAS::FourVector match(const DAS::FourVector &jet, const std::vector< DAS::FourVector > *hltJets)
Definition: match.h:7
void set_mute(bool flag)
Function used by Boost::PO to disable standard error.
Definition: Options.cc:93
static const char * bold
Definition: Step.h:35