diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-01-18 18:44:22 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-01-18 18:44:22 +0100 |
| commit | c9a3ebd623bf2f968f7fbdf5bb2d7dda480b9f1c (patch) | |
| tree | e1a1837c62ffcf7cd0255395cdc449430cb9f352 /cli/configuration.cpp | |
| parent | 2485d00c4c40713b6cb3c39595d69ea2cf497b47 (diff) | |
| download | katja-c9a3ebd623bf2f968f7fbdf5bb2d7dda480b9f1c.tar.gz | |
Parse command line with boost program_options
Diffstat (limited to 'cli/configuration.cpp')
| -rw-r--r-- | cli/configuration.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/cli/configuration.cpp b/cli/configuration.cpp index 45669b3..4ca36c1 100644 --- a/cli/configuration.cpp +++ b/cli/configuration.cpp @@ -7,6 +7,7 @@ module; #include <string> #include <forward_list> +#include <stdexcept> #include <toml.hpp> @@ -15,8 +16,6 @@ import katja.repository; export module katja.configuration; -import katja.component; - export namespace katja { struct repository_configuration @@ -58,17 +57,30 @@ export namespace katja return this->repositories.cend(); } }; + + class configuration_error : public std::runtime_error + { + public: + configuration_error() + : std::runtime_error("Configuration is expected to be a table of repositories.") + { + } + }; } TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(katja::repository_configuration, path); export namespace katja { - configuration read_configuration() + configuration read_configuration(const std::string& configuration_file) { - auto raw_root = toml::parse("katja.toml"); + auto raw_root = toml::parse(configuration_file); configuration result; + if (!raw_root.is_table()) + { + throw configuration_error(); + } for (const auto& [root_name, root_value] : raw_root.as_table()) { auto repository_value = toml::get<repository_configuration>(root_value); |
