@@ -562,6 +562,7 @@ void DeviceSpecHelpers::prepareArguments(int argc, char** argv, bool defaultQuie
562562 std::vector<DeviceExecution>& deviceExecutions,
563563 std::vector<DeviceControl>& deviceControls)
564564{
565+ assert (argc > 0 ); // we require to have the program name as the first argument
565566 assert (deviceSpecs.size () == deviceExecutions.size ());
566567 assert (deviceControls.size () == deviceExecutions.size ());
567568 for (size_t si = 0 ; si < deviceSpecs.size (); ++si) {
@@ -591,19 +592,23 @@ void DeviceSpecHelpers::prepareArguments(int argc, char** argv, bool defaultQuie
591592 std::vector<std::string> tmpArgs = { argv[0 ], " --id" , spec.id .c_str (), " --control" , " static" ,
592593 " --log-color" , " false" , " --color" , " false" };
593594
594- // do the filtering of options, forward options belonging to this specific
595- // DeviceSpec, and some global options from getForwardedDeviceOptions
595+ // do the filtering of options:
596+ // 1) forward options belonging to this specific DeviceSpec
597+ // 2) global options defined in getForwardedDeviceOptions and workflow option are
598+ // always forwarded and need to be handled separately
596599 const char * name = spec.name .c_str ();
597- bpo::options_description od;
598- bpo::options_description wo;
600+ bpo::options_description od; // option descriptions per process
601+ bpo::options_description foDesc; // forwarded options for all processes
599602 ConfigParamsHelper::prepareOptionsDescription (spec.options , od);
600- ConfigParamsHelper::prepareOptionsDescription (workflowOptions, wo);
601- od.add (getForwardedDeviceOptions ());
602- od.add (wo);
603603 od.add_options ()(name, bpo::value<std::string>());
604+ ConfigParamsHelper::prepareOptionsDescription (workflowOptions, foDesc);
605+ foDesc.add (getForwardedDeviceOptions ());
604606
605607 using FilterFunctionT = std::function<void (decltype (argc), decltype (argv), decltype (od))>;
606608
609+ // the filter function will forward command line arguments based on the option
610+ // definition passed to it. All options of the program option definition will be forwarded
611+ // if found in the argument list. If not found they will be added with the default value
607612 FilterFunctionT filterArgsFct = [&](int largc, char ** largv, const bpo::options_description& odesc) {
608613 // spec contains options
609614 bpo::command_line_parser parser{ largc, largv };
@@ -667,6 +672,9 @@ void DeviceSpecHelpers::prepareArguments(int argc, char** argv, bool defaultQuie
667672 }
668673 };
669674
675+ // filter global options and workflow options independent of option groups
676+ filterArgsFct (argc, argv, foDesc);
677+ // filter device options, and handle option groups
670678 filterArgsFct (argc, argv, od);
671679
672680 // Add the channel configuration
@@ -697,7 +705,7 @@ void DeviceSpecHelpers::prepareArguments(int argc, char** argv, bool defaultQuie
697705 }
698706}
699707
700- // / define the options which are forwarded to the FairMQ device
708+ // / define the options which are forwarded to every child
701709boost::program_options::options_description DeviceSpecHelpers::getForwardedDeviceOptions ()
702710{
703711 // - rate is an option of FairMQ device for ConditionalRun
0 commit comments