 |
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 () |
|
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::vector< std::filesystem::path > | plugins () 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 () |
|
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::vector< std::filesystem::path > | plugins () 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 |
111 (
"prefix,%", po::value<fs::path>(&
prefix),
"Prefix command, `parallel` or `submit` (for history only)");
115 (
"help,h",
"Help screen (what you are seeing right now)")
116 (
"tutorial,t",
"Brief description of the command's purpose")
117 (
"git,g",
"Commit hash of this executable at compilation time")
118 (
"input_ext,i",
"Expected extension for input(s) (one line for each input)")
119 (
"output_ext,o",
"Expected extension for output(s) (one line for each output)");
121 (
"example,e",
"Print config example");
125 (
"verbose,v", po::bool_switch()->default_value(
false),
126 "Enable debug mode (typically in slow operations such as the event loop)")
127 (
"mute,m", po::bool_switch()->default_value(
false)->notifier(
set_mute),
128 "Disable standard output stream");
131 "Configuration file in INFO, JSON, or XML format");
133 (
"nSplit,j", po::value<int>(&
j)->default_value(
j),
"Number of slices")
134 (
"nNow,k" , po::value<int>(&
k)->default_value(
k),
"Index of current slice");
136 (
"fill,f", po::bool_switch()->default_value(
false),
"Enable `TTree::Fill()`");
138 (
"Friend,F", po::bool_switch()->default_value(
false),
139 "Use `TTree` friends instead of cloning the whole input `TTree`");
141 (
"syst,s", po::bool_switch()->default_value(
false),
142 "Enable systematic variations");
144 (
"plugin,p", po::value<vector<fs::path>>(&
plugin_paths)->multitoken()->composing(),
145 "Specify a plugin to run before filling the tree (multiple use is allowed)");
◆ Options() [2/4]
No default constructor is allowed.
◆ ~Options() [1/2]
Destructor.
193 {
if (
steer &
verbose) std::cout <<
"Options: destroying options" << std::endl; }
◆ 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.
◆ ~Options() [2/2]
Destructor.
193 {
if (
steer &
verbose) std::cout <<
"Options: destroying options" << std::endl; }
◆ 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 |
238 if (
stage > Stage::Arg)
239 BOOST_THROW_EXCEPTION(std::runtime_error(
240 "Not possible to add another argument at this stage"));
245 const boost::program_options::value_semantic * s =
246 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 |
238 if (
stage > Stage::Arg)
239 BOOST_THROW_EXCEPTION(std::runtime_error(
240 "Not possible to add another argument at this stage"));
245 const boost::program_options::value_semantic * s =
246 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 |
555 if (
stage >= Stage::Args)
556 BOOST_THROW_EXCEPTION(runtime_error(
"Only one garbage collector is possible"));
563 const po::value_semantic * s =
564 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
-
41 if (!fs::exists(
input))
42 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Bad input",
input,
43 make_error_code(errc::no_such_file_or_directory)));
48 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Input exists but cannot be read",
49 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
-
54 fs::path outputHist =
output;
55 if (!
prefix.empty() && !fs::is_directory(
output)) outputHist.remove_filename();
56 full_cmd +=
' ' + outputHist.string();
58 if (!fs::exists(
output))
return;
60 if ((fs::status(
output).permissions() & fs::perms::owner_write)
63 BOOST_THROW_EXCEPTION(fs::filesystem_error(
64 "Output already exists and cannot be overwritten",
65 output, make_error_code(errc::permission_denied)));
68 if (fs::is_directory(
output) && fs::equivalent(
output,
".")) {
70 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Not a valid output",
71 output, make_error_code(errc::invalid_argument)));
73 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 & |
| ) |
|
|
private |
- Returns
- output from command given to shell
◆ exec() [2/2]
std::string exec |
( |
const std::string & |
cmd | ) |
|
|
private |
- Returns
- output from command given to shell
- Parameters
-
cmd | cmd to run in the shell |
483 FILE * pipe = popen(
cmd.c_str(),
"r");
485 if (fgets(buffer, 128, pipe) != NULL)
◆ 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 |
468 if (
stage > Stage::Input)
469 BOOST_THROW_EXCEPTION(runtime_error(
470 "Not possible to add another input at this stage"));
473 const po::value_semantic * s =
474 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 |
496 if (
stage > Stage::Input)
497 BOOST_THROW_EXCEPTION(runtime_error(
498 "Not possible to add another input at this stage"));
500 auto store = [
files,
this](
const string& pathRegex) {
502 const string& ls =
exec(
"ls -1d " + pathRegex);
504 vector<fs::path>
paths;
506 for (fs::path
const&
p:
paths) {
507 if (!fs::exists(
p))
continue;
511 if (
files->empty()) {
512 fs::path
p = pathRegex;
514 BOOST_THROW_EXCEPTION(
515 fs::filesystem_error(
"No input file could be found",
p,
516 make_error_code(errc::no_such_file_or_directory)));
521 return inputs + fs::canonical(input).string() +
' '; });
523 if (
files->size() > 1)
529 const po::value_semantic * s =
530 po::value<string>()->notifier(store)->required();
531 string full_desc = desc;
532 full_desc +=
" (use a regular expression, surrounded by quotation marks)";
533 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.
438 p = fs::canonical(
p);
445 catch (
const po::error& e) {
446 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 |
539 if (
stage > Stage::Output) {
541 BOOST_THROW_EXCEPTION(runtime_error(
542 "Not possible to add another output at this stage"));
544 stage = Stage::Output;
547 const po::value_semantic * s =
548 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.
275 po::options_description cmd_line;
279 po::command_line_parser
parser{argc, argv};
281 .allow_unregistered();
283 po::variables_map vm;
284 po::store(
parser.run(), vm);
287 if (vm.count(
"nSplit")) {
288 auto j = vm[
"nSplit"].as<
int>();
290 BOOST_THROW_EXCEPTION(
291 invalid_argument(
"The number of slices must be larger than 0") );
293 if (vm.count(
"nNow")) {
294 auto k = vm[
"nNow"].as<
int>();
296 BOOST_THROW_EXCEPTION(
297 invalid_argument(
"The slice index must be smaller than the "
298 "number of slices.") );
302 if (vm.count(
"config")) {
306 else if (ext ==
".xml" ) {
309 pt_conf = userinfo.get_child(
"userinfo");
311 else BOOST_THROW_EXCEPTION(
312 fs::filesystem_error(
"Extension should be .json, .xml, or .info",
313 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 |
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.
326 po::options_description cmd_line;
331 po::command_line_parser
parser{argc, argv};
335 po::variables_map vm;
336 po::parsed_options parsed =
parser.run();
337 po::store(parsed, vm);
342 if (vm.count(
name))
continue;
343 throw po::required_option(
name);
355 auto arg =
pt_conf.get_optional<
string>(configpath);
357 al::erase_all(*
arg,
"\n");
358 al::erase_all(*
arg,
" ");
359 al::erase_all(*
arg,
"\"");
360 if (
arg->empty())
continue;
367 if (!
pt_conf.count(configpath))
368 pt_conf.add<
string>(configpath,
"");
369 auto& subtree =
pt_conf.get_child(configpath);
371 for (
const auto& [
key, value]: subtree) {
372 const auto v = value.get_value<
string>();
373 if (
key.empty() ||
key ==
"item")
379 vector<string> items = po::collect_unrecognized(parsed.options,
380 po::include_positional);
383 items.erase(items.begin(), items.begin() + *
registered);
385 for (
string item: items) {
386 if (subtree.count(item))
continue;
390 pt::ptree::path_type
p(item,
'\0');
391 subtree.put<
string>(
p,
"");
◆ parse_custom() [2/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_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 |
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.
190 po::command_line_parser
parser{argc, argv};
192 .allow_unregistered();
195 po::variables_map vm;
196 po::store(
parser.run(), vm);
199 if (vm.count(
"help") || argc == 1) {
200 fs::path executable = argv[0];
203 for (
const auto& option:
custom.options())
204 cout <<
'\t' << option->long_name()
205 <<
" = " << option->description() <<
'\n';
208 if (vm.count(
"help")) {
209 po::options_description cmd_line;
213 cout << cmd_line << endl;
216 if (vm.count(
"tutorial"))
219 "unless stated otherwise, all options except the input and output files "
220 "may be given either from the command line or from such a config. Unused "
221 "options in the config are simply ignored. The `flags` should be set at "
222 "the creation of the n-tuples; the `corrections` should be added step "
223 "by step (typically a couple of corrections per executable at most). How "
224 "the config is parsed may change from executable to executable. This "
225 "example uses the Boost INFO format, but JSON and XML formats are also "
226 "possible. It is possible to extract such a config from an existing ROOT "
227 "file by using `getMetaInfo`. Arguments from command line overwrite "
228 "arguments from the config.") << endl;
233 if (vm.count(
"example")) {
235 BOOST_THROW_EXCEPTION(
236 fs::filesystem_error(
"The example could not be found",
237 example, make_error_code(errc::no_such_file_or_directory)));
240 pt::ptree reduced_config;
243 reduced_config.add<
string>(
key, value);
247 write_info(ss, reduced_config);
248 string str = ss.str();
249 al::erase_all(str,
"\"\"");
250 cout << str << flush;
253 auto space_separate = [](
const string& a,
const string& b) {
257 if (vm.count(
"input_ext"))
258 for (
const vector<string>& ext:
inputExt)
260 cout << accumulate(next(begin(ext)), end(ext),
261 ext.front(), space_separate) << endl;
263 if (vm.count(
"output_ext"))
264 for (
const vector<string>& ext:
outputExt)
266 cout << accumulate(next(begin(ext)), end(ext),
267 ext.front(), space_separate) << endl;
269 if (!vm.empty() || argc == 1)
◆ parse_helper() [2/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.
◆ plugins() [1/2]
std::vector<std::filesystem::path> plugins |
( |
| ) |
const |
|
inline |
Plugins to run in the executable
- Todo:
- Save in config ptree? (also need to think of reproducibility)
306 BOOST_THROW_EXCEPTION( runtime_error(
"Plugins have not been activated") );
◆ plugins() [2/2]
std::vector<std::filesystem::path> plugins |
( |
| ) |
const |
|
inline |
Plugins to run in the executable
- Todo:
- Save in config ptree? (also need to think of reproducibility)
306 BOOST_THROW_EXCEPTION( runtime_error(
"Plugins have not been activated") );
◆ 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 |
137 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 |
137 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
-
456 BOOST_THROW_EXCEPTION(invalid_argument(
457 "Once `Options::args()` has been called, "
458 "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.
316 BOOST_THROW_EXCEPTION(invalid_argument(
"No splitting of the input file."));
317 return make_pair(
j,
k);
◆ slice() [2/2]
std::pair<unsigned, unsigned> slice |
( |
| ) |
const |
|
inline |
Compactify slice information into a pair.
316 BOOST_THROW_EXCEPTION(invalid_argument(
"No splitting of the input file."));
317 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
◆ plugin_paths
std::vector< std::filesystem::path > plugin_paths |
|
private |
◆ 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:105
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:369
p
Definition: Ntupliser_cfg.py:178
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:330
static const char * orange
Definition: colours.h:6
string wrap_paragraph(const string &text)
Definition: Options.cc:154
#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:95
static const char * bold
Definition: Step.h:35