Parse command line with boost program_options
Some checks failed
Test / build (push) Failing after 16s
Some checks failed
Test / build (push) Failing after 16s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user