/* * 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/. */ #include #include #include #include #include import katja.database; import katja.repository; import katja.sbo; import katja.configuration; import katja.command_line; static void get_updates(std::shared_ptr repository, katja::package_database&& installed_database) { const std::vector packages = repository->get_updates(installed_database); for (const auto& package_identifier : packages) { std::cout << package_identifier.to_string() << std::endl; } std::cout << std::endl << "Updates " << '(' << packages.size() << ')' << std::endl; } static void search_names(std::shared_ptr repository, const std::string& needle) { const std::vector packages = repository->search_names("x86-64", needle); for (const auto& package_identifier : packages) { std::cout << package_identifier.to_string() << std::endl; } } static void handle_subcommand(const katja::configuration& configuration, const katja::subcommand& command) { if (std::holds_alternative(command)) { katja::package_database installed_database = katja::read_installed_database(); for (const auto& [repository_name, repository_configuration] : configuration) { std::filesystem::path slackbuild_repository{ repository_configuration.path }; auto repository = std::make_shared(slackbuild_repository); get_updates(repository, std::move(installed_database)); } } else if (std::holds_alternative(command)) { for (const auto& [repository_name, repository_configuration] : configuration) { std::filesystem::path slackbuild_repository{ repository_configuration.path }; auto repository = std::make_shared(slackbuild_repository); search_names(repository, std::get(command).needle); } } } int main(int argc, const char **argv) { katja::configuration configuration = katja::read_configuration("katja.toml"); katja::command_line command_line = katja::parse_command_line(argc, argv); katja::subcommand subcommand = katja::parse_subcommand(command_line); handle_subcommand(configuration, subcommand); return EXIT_SUCCESS; }