blob: 8a8a37794a8b9276d5d8c98ca2899d3aa93b9bfd (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
/*
* 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 <iostream>
#include <toml.hpp>
import katja.database;
import katja.repository;
import katja.sbo;
import katja.configuration;
static void get_updates(std::shared_ptr<katja::repository> repository, katja::package_database&& installed_database)
{
const std::vector<katja::package_identifier> 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<katja::repository> repository, const std::string& needle)
{
const std::vector<katja::package_identifier> packages = repository->search_names("x86-64", needle);
for (const auto& package_identifier : packages)
{
std::cout << package_identifier.to_string() << std::endl;
}
}
int main(int argc, const char **argv)
{
katja::configuration configuration = katja::read_configuration();
katja::package_database installed_database = katja::read_installed_database();
if (argc == 1)
{
return EXIT_FAILURE;
}
if (strcmp("updates", argv[1]) == 0)
{
for (const auto& [repository_name, repository_configuration] : configuration)
{
std::filesystem::path slackbuild_repository{ repository_configuration.path };
auto repository = std::make_shared<katja::sbo_repository>(slackbuild_repository);
get_updates(repository, std::move(installed_database));
}
}
else if (strcmp("search", argv[1]) == 0 && argc == 3)
{
for (const auto& [repository_name, repository_configuration] : configuration)
{
std::filesystem::path slackbuild_repository{ repository_configuration.path };
auto repository = std::make_shared<katja::sbo_repository>(slackbuild_repository);
search_names(repository, std::string(argv[2]));
}
}
return EXIT_SUCCESS;
}
|