21 #include <boost/program_options.hpp>
23 using namespace boost::program_options;
28 options_description desc(
"Allowed options" );
29 desc.add_options()(
"help,h",
"produce help message" )(
"config", value<std::string>(),
30 "comma separated list of python configuration files" )(
31 "post-option", value<std::string>(),
"python command to be run after ConfigurableUser has been applied" )(
32 "param", value<std::vector<std::string>>(),
"parameters to the configuration file, multiple can be given" );
33 positional_options_description p;
37 store( command_line_parser(
argc,
argv ).
options( desc ).positional( p ).run(), vm );
38 }
catch ( boost::exception_detail::clone_impl<
39 boost::exception_detail::error_info_injector<boost::program_options::unknown_option>>& ) {
40 std::cerr <<
"Unknown option(s) detected." << std::endl <<
"Usage:" << std::endl << desc << std::endl;
47 if ( vm.count(
"help" ) or vm.count(
"h" ) ) {
48 std::cout << desc << std::endl;
51 if ( !vm.count(
"config" ) ) {
52 std::cout <<
"Please specify a config file" << std::endl;
55 fileName = vm[
"config"].as<std::string>();
58 std::stringstream params;
59 if ( 0 != vm.count(
"param" ) ) {
60 std::vector<std::string> vParams = vm[
"param"].as<std::vector<std::string>>();
61 std::cout <<
"Configuration parameters are:" << std::endl;
62 for (
const std::string&
s : vParams ) {
64 std::cout <<
"\t" <<
s << std::endl;
68 std::string postAction;
69 if ( 0 != vm.count(
"post-option" ) ) { postAction = vm[
"post-option"].as<std::string>(); }
75 propMgr->setProperty(
"JobOptionsType",
"PYTHON" ).ignore( );
76 propMgr->setProperty(
"JobOptionsPath", fileName ).ignore( );
77 propMgr->setProperty(
"JobOptionsPreAction", params.str() ).ignore( );
78 propMgr->setProperty(
"JobOptionsPostAction", postAction )
80 return appUI->run().getCode();