| 237 | } |
| 238 | |
| 239 | Config readConfig(std::filesystem::path path) |
| 240 | { |
| 241 | Config config; |
| 242 | for (;;) { |
| 243 | if (std::filesystem::exists(path)) { |
| 244 | toml::table tbl; |
| 245 | try { |
| 246 | tbl = toml::parse_file((path).string()); |
| 247 | } catch (toml::parse_error const& err) { |
| 248 | std::cerr << "Configuration parsing failed:\n" << err << '\n'; |
| 249 | exit(1); |
| 250 | } |
| 251 | |
| 252 | config.read(tbl); |
| 253 | if (config.printing.verbose) { |
| 254 | std::cout << "Found: " << (path) << '\n'; |
| 255 | } |
| 256 | |
| 257 | break; |
| 258 | } |
| 259 | if (!path.has_parent_path()) { |
| 260 | std::cout << "Did not find configuration file, using default.\n"; |
| 261 | break; |
| 262 | } |
| 263 | path = path.parent_path(); |
| 264 | } |
| 265 | |
| 266 | if (config.printing.verbose) { |
| 267 | std::cout << config << '\n'; |
| 268 | } |
| 269 | |
| 270 | return config; |
| 271 | } |
| 272 | |
| 273 | ufo::Color randomColor() |
| 274 | { |
no test coverage detected