7#ifndef __GS_ARG_PARSER_H__
8#define __GS_ARG_PARSER_H__
10#include <scp/report.h>
11#include <cci_configuration>
16#include <scp/report.h>
19#include "luafile_tool.h"
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;
57 SCP_INFO(()) <<
"Setting param " <<
key <<
" to value " << value;
59 return std::make_pair(
key, value);
71 SCP_INFO(()) <<
"Parse command line for --gs_luafile option (" <<
argc <<
" arguments)";
75 std::vector<std::unique_ptr<char[]>>
argv_cp;
77 for (
int i = 0;
i <
argc;
i++) {
79 argv_cp.emplace_back(std::make_unique<
char[]>(
len));
103 SCP_INFO(()) <<
"Lua file command line parser: parse option --gs_luafile " <<
optarg << std::endl;
112 a_broker.set_preset_cci_value(
param.first, cci::cci_value(cci::cci_value::from_json(
param.second)));
123 SCP_FATAL(()) <<
"fatal: missing required --gs_luafile argument";
Definition argparser.h:27
std::pair< std::string, std::string > get_key_val_args(const std::string &arg)
convert "foo=bar" kind of command line arg to std::pair<std::string, std::string>
Definition argparser.h:45
void parseCommandLineWithGetOpt(cci::cci_broker_handle a_broker, const int argc, const char *const *argv, bool enforce_config_file)
Parses the command line with getopt and extracts the luafile option.
Definition argparser.h:68