summaryrefslogtreecommitdiff
path: root/src/command.cpp
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-04-15 08:43:30 +0200
committerEugen Wissner <belka@caraus.de>2023-04-15 08:43:30 +0200
commit34b10f41aa285e423cccb161342b68ae7275da4b (patch)
treee021c107400ec467b59a019c45d6659110c677cf /src/command.cpp
parentdbf14caee2f3ffbcfb21d5ca4d1566e0f57a1aed (diff)
downloadslackbuilder-34b10f41aa285e423cccb161342b68ae7275da4b.tar.gz
Retrieve updatable packages
Diffstat (limited to 'src/command.cpp')
-rw-r--r--src/command.cpp67
1 files changed, 40 insertions, 27 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 0fa6bf1..9443372 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -1,18 +1,52 @@
#include "command.h"
#include <cassert>
#include "config.h"
+#include "sbo.h"
+#include <ftxui/dom/elements.hpp>
+#include <ftxui/component/screen_interactive.hpp>
+#include "component.h"
namespace katja
{
void list::execute() const
{
- for (const auto& package : katja::read_package_database())
+ sbo sbo_repository;
+ std::unordered_map<std::string, package> packages = katja::read_package_database();
+ std::vector<std::vector<std::string>> table_data;
+ std::set<std::string> installed_packages;
+ std::unordered_map<std::string, package> package_database = read_package_database();
+
+ for (const auto& package : package_database)
{
- std::cout << package.second.name()
- << " " << package.second.version()
- << " (" << package.second.tag() << ")"
- << std::endl;
+ std::string tag = package.second.tag();
+ if (tag.find("_SBo") == std::string::npos)
+ {
+ continue;
+ }
+ installed_packages.insert(package.first);
}
+ for (const auto& package : sbo_repository.list(installed_packages))
+ {
+ if (package_database.find(package.first)->second.version() == package.second.version())
+ {
+ continue;
+ }
+ table_data.push_back({
+ package.second.name(),
+ package.second.version(),
+ package.second.tag(),
+ package.second.architecture(),
+ "SBo"
+ });
+ }
+
+ auto screen = ftxui::ScreenInteractive::Fullscreen();
+ PackageList list_component{
+ { "Package name", "Version", "Tag", "Architecture", "Repository" },
+ table_data
+ };
+
+ screen.Loop(std::make_shared<PackageList>(list_component));
}
void help::execute() const
@@ -21,30 +55,9 @@ namespace katja
"\tkatja {list|update|help} [OPTIONS]\n\n";
}
- update::update()
- : git_binary(boost::process::search_path("git"))
- {
- }
-
void update::execute() const
{
- std::filesystem::path workdir{ WORKDIR };
- std::filesystem::path repository = workdir / "sbo/repository";
- std::filesystem::file_status repository_status = std::filesystem::status(repository);
-
- if (std::filesystem::exists(repository_status)
- && !std::filesystem::is_directory(repository_status))
- {
- throw std::runtime_error("The working directory path \""
- + repository.string() + "\" exists, but it isn't a directory.");
- }
- else if (!std::filesystem::exists(repository_status))
- {
- git("clone", std::filesystem::path(),
- "git://git.slackbuilds.org/slackbuilds.git", repository.native());
- }
- git("remote", repository.native(), "update", "--prune");
- git("reset", repository.native(), "--hard", "origin/master");
+ sbo().refresh();
}
command_exception::command_exception(const command_exception_t exception_type,