summaryrefslogtreecommitdiff
path: root/cli/main.cpp
blob: a204d2fa828d9eba83ef3569af8b3b1f9fe47a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <filesystem>

#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/dom/elements.hpp>
#include <toml.hpp>

#include "katja/sbo.hpp"
#include "katja/database.hpp"
#include "component.hpp"

int main(int argc, const char **argv)
{
    auto configuration = toml::parse("katja.toml");
    katja::package_database installed_database = katja::read_installed_database();

    for (const auto& [repository_name, repository_value] : configuration.as_table())
    {
        std::filesystem::path slackbuild_repository{ repository_value.at("path").as_string() };
        auto repository = std::make_shared<katja::sbo_repository>(slackbuild_repository);

        auto screen = ftxui::ScreenInteractive::Fullscreen();

        auto container = Screen(std::vector<std::pair<std::string, katja::Page>>{
            { "Home", ftxui::Make<katja::WelcomePage>() },
            { "Updates", ftxui::Make<katja::UpdatesPage>(repository, std::move(installed_database)) },
            { "Search", ftxui::Make<katja::SearchPage>(repository, "x86-64") }
        }, screen.ExitLoopClosure());

        screen.Loop(container);
    }
    return EXIT_SUCCESS;
}