47 std::stringstream ss(arg);
48 std::string key, value;
50 if (!std::getline(ss, key,
'=')) {
51 SCP_FATAL(()) <<
"parameter name not found!" << std::endl;
53 if (!std::getline(ss, value)) {
54 SCP_FATAL(()) <<
"parameter value not found!" << std::endl;
61 if (!value.empty() && value[0] !=
'"' && value[0] !=
'[' && value[0] !=
'{' && value !=
"true" &&
62 value !=
"false" && value !=
"null" && !std::isdigit(value[0]) && value[0] !=
'-') {
63 value =
"\"" + value +
"\"";
66 SCP_INFO(()) <<
"Setting param " << key <<
" to value " << value;
68 return std::make_pair(key, value);
78 bool enforce_config_file)
80 SCP_INFO(()) <<
"Parse command line for --gs_luafile option (" << argc <<
" arguments)";
82 bool luafile_found =
false;
83 char* images_dir = NULL;
85 std::vector<std::unique_ptr<char[]>> argv_cp;
86 char* argv_cp_raw[argc];
87 for (
int i = 0; i < argc; i++) {
88 size_t len = strlen(argv[i]) + 1;
89 argv_cp.emplace_back(std::make_unique<
char[]>(len));
90 strcpy(argv_cp[i].get(), argv[i]);
91 argv_cp_raw[i] = argv_cp[i].get();
99 const char* optstring =
"l:p:";
101 struct option long_options[] = { {
"gs_luafile", required_argument, 0,
'l' },
102 {
"param", required_argument, 0,
'p' },
103 {
"images-dir", required_argument, 0,
'i' },
108 int c = getopt_long(argc, argv_cp_raw, optstring, long_options, 0);
110 if (c ==
'i') images_dir = optarg;
115 int c = getopt_long(argc, argv_cp_raw, optstring, long_options, 0);
121 SCP_INFO(()) <<
"Option --gs_luafile with value " << optarg;
122 SCP_INFO(()) <<
"Lua file command line parser: parse option --gs_luafile " << optarg << std::endl;
123 lua.config(a_broker, optarg, images_dir);
124 luafile_found =
true;
131 a_broker.set_preset_cci_value(param.first, cci::cci_value(cci::cci_value::from_json(param.second)));
141 if (enforce_config_file && !luafile_found) {
142 SCP_FATAL(()) <<
"fatal: missing required --gs_luafile argument";