diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-03-22 20:32:47 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-03-22 20:32:47 +0100 |
| commit | 69bf515582f867b8521cf97ddd310e8dfdf1238b (patch) | |
| tree | c8e2261d1a3e80c4d67862e083daa858b621e7d3 /cli/main.cpp | |
| parent | 9bec46cc1fb6a03d320955054a10154264a3d4ac (diff) | |
| download | kazbek-69bf515582f867b8521cf97ddd310e8dfdf1238b.tar.gz | |
katja: Add TUI and TOML libraries
Diffstat (limited to 'cli/main.cpp')
| -rw-r--r-- | cli/main.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/cli/main.cpp b/cli/main.cpp index c257dbd..788f620 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -1,24 +1,43 @@ #include <filesystem> #include <iostream> +#include <ftxui/dom/elements.hpp> +#include <ftxui/screen/screen.hpp> +#include <ftxui/screen/string.hpp> +#include <toml.hpp> + #include "katja/sbo.hpp" #include "katja/database.hpp" int main(int argc, const char **argv) { - std::multimap<std::string, katja::database_package> installed_database = katja::read_installed_database(); + auto configuration = toml::parse("config/katja.toml"); - if (argc > 1) + for (const auto& [repository_name, repository_value] : configuration.as_table()) { - std::filesystem::path slackbuild_repository{ argv[1] }; + std::multimap<std::string, katja::database_package> installed_database = katja::read_installed_database(); + + std::filesystem::path slackbuild_repository{ repository_value.at("path").as_string() }; katja::sbo_repository repository{ slackbuild_repository }; auto updates = repository.get_updates(installed_database); + std::vector<std::shared_ptr<ftxui::Node>> lines; + for (const auto& package_identifier : updates) { - std::cout << package_identifier.to_string() << std::endl; + auto line = ftxui::text(package_identifier.to_string()) | color(ftxui::Color::SkyBlue2); + lines.push_back(line); } - std::cout << "SlackBuilds found: " << updates.size() << std::endl; + ftxui::Element summary = ftxui::text(" Updates (" + std::to_string(lines.size()) + ")"); + auto document = ftxui::window(summary, ftxui::vbox(lines)); + + // Limit the size of the document to 80 char. + document = document | size(ftxui::WIDTH, ftxui::LESS_THAN, 80); + auto screen = ftxui::Screen::Create(ftxui::Dimension::Full(), ftxui::Dimension::Fit(document)); + + ftxui::Render(screen, document); + + std::cout << screen.ToString() << '\0' << std::endl; } - return 0; + return EXIT_SUCCESS; } |
