From 2485d00c4c40713b6cb3c39595d69ea2cf497b47 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 15 Jan 2026 20:26:54 +0100 Subject: Add a simple CLI instead of TUI --- cli/configuration.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 cli/configuration.cpp (limited to 'cli/configuration.cpp') diff --git a/cli/configuration.cpp b/cli/configuration.cpp new file mode 100644 index 0000000..45669b3 --- /dev/null +++ b/cli/configuration.cpp @@ -0,0 +1,79 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ +module; + +#include +#include + +#include + +import katja.database; +import katja.repository; + +export module katja.configuration; + +import katja.component; + +export namespace katja +{ + struct repository_configuration + { + std::string path; + }; + + class configuration + { + public: + using repositories_t = std::forward_list>; + + private: + repositories_t repositories; + + public: + void add(const std::string& name, repository_configuration&& repository) + { + this->repositories.emplace_front(name, std::move(repository)); + } + + repositories_t::iterator begin() + { + return this->repositories.begin(); + } + + repositories_t::iterator end() + { + return this->repositories.end(); + } + + repositories_t::const_iterator cbegin() + { + return this->repositories.cbegin(); + } + + repositories_t::const_iterator cend() + { + return this->repositories.cend(); + } + }; +} + +TOML11_DEFINE_CONVERSION_NON_INTRUSIVE(katja::repository_configuration, path); + +export namespace katja +{ + configuration read_configuration() + { + auto raw_root = toml::parse("katja.toml"); + configuration result; + + for (const auto& [root_name, root_value] : raw_root.as_table()) + { + auto repository_value = toml::get(root_value); + result.add(root_name, std::move(repository_value)); + } + return result; + } +} -- cgit v1.2.3