| 223 | } |
| 224 | |
| 225 | void |
| 226 | FileConfigCommand::config_get() |
| 227 | { |
| 228 | auto filename = get_parsed_arguments()->get(COLD_STR).value(); // could be empty which means we should use the default file name |
| 229 | auto const &data = get_parsed_arguments()->get(GET_STR); |
| 230 | std::string text; |
| 231 | |
| 232 | fix_filename(filename); |
| 233 | try { |
| 234 | FlatYAMLAccessor::load(YAML::LoadAllFromFile(filename)); |
| 235 | |
| 236 | for (auto const &var : data) { // we support multiple get's |
| 237 | std::string variable = amend_variable_name(var); |
| 238 | auto [found, search] = find_node(variable); |
| 239 | |
| 240 | if (found) { |
| 241 | _printer->write_output(swoc::bwprint(text, "{}: {}", var, search.as<std::string>())); |
| 242 | } else { |
| 243 | _printer->write_output(swoc::bwprint(text, "{} not found", var)); |
| 244 | } |
| 245 | } |
| 246 | } catch (YAML::Exception const &ex) { |
| 247 | throw std::logic_error(swoc::bwprint(text, "config get error: {}", ex.what())); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | void |
| 252 | FileConfigCommand::config_set() |
nothing calls this directly
no test coverage detected