Skip to content

Commit

Permalink
commands: fix prep commands when empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Mar 27, 2023
1 parent 1dfe9ea commit d6de09b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,12 +762,18 @@ void list_string_f(std::unordered_map<std::string, std::string> &vars, const std
input.emplace_back(begin, pos);
}
}

void list_prep_cmd_f(std::unordered_map<std::string, std::string> &vars, const std::string &name, std::vector<prep_cmd_t> &input) {
std::string string;
string_f(vars, name, string);

std::stringstream jsonStream;

// check if string is empty, i.e. when the value doesn't exist in the config file
if(string.empty()) {
return;
}

// We need to add a wrapping object to make it valid JSON, otherwise ptree cannot parse it.
jsonStream << "{\"prep_cmd\":" << string << "}";

Expand Down

0 comments on commit d6de09b

Please sign in to comment.