Browse Source

fix command-line kvargs

feature/new-parser
Martin Dørum 3 years ago
parent
commit
9af75d8cc0
2 changed files with 5 additions and 4 deletions
  1. 4
    4
      cmd/main.cc
  2. 1
    0
      lib/BXParser.cc

+ 4
- 4
cmd/main.cc View File

@@ -19,7 +19,7 @@
struct Conf {
std::vector<std::string> args;
std::vector<std::string> args2;
std::vector<std::pair<std::string, std::string>> kwargs;
std::vector<std::pair<std::string, std::string>> kvargs;
bool exec = false;
};

@@ -54,7 +54,7 @@ static void run(Conf conf) {
parser.parse(variables);
}

for (auto &pair: conf.kwargs) {
for (auto &pair: conf.kvargs) {
bufio::ISStream ss(pair.second);
BXParser parser(ss);
auto &list = variables[pair.first];
@@ -62,7 +62,7 @@ static void run(Conf conf) {
parser.parseList(variables, list);
}

if (conf.kwargs.size() > 0) {
if (conf.kvargs.size() > 0) {
bufio::OFStream f(path + "/.config.bx");
BXWriter w(f);
w.write(variables);
@@ -238,7 +238,7 @@ int main(int argc, char **argv) {
if (eq == nullptr) {
conf.args.push_back(arg);
} else {
conf.kwargs.push_back(std::make_pair(
conf.kvargs.push_back(std::make_pair(
std::string(arg, eq - arg), std::string(eq + 1)));
}
}

+ 1
- 0
lib/BXParser.cc View File

@@ -411,5 +411,6 @@ void BXParser::parseList(BXVariables &vars, std::vector<std::string> &var) {
var.push_back(std::move(val));
};

readToken(vars);
parseList(vars, var, addVal, false);
}

Loading…
Cancel
Save