summaryrefslogtreecommitdiff
path: root/cli/main.cpp
blob: 5502800bc62a344c1f862b58d5119878b96bcf62 (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
33
34
35
36
37
38
39
40
41
42
/*
 * 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 <filesystem>
#include <memory>

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

import katja.database;
import katja.repository;
import katja.sbo;
import katja.page;

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;
}