diff options
Diffstat (limited to 'src/command.cpp')
| -rw-r--r-- | src/command.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/command.cpp b/src/command.cpp index 4066c23..0fa6bf1 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -1,5 +1,6 @@ #include "command.h" #include <cassert> +#include "config.h" namespace katja { @@ -17,7 +18,33 @@ namespace katja void help::execute() const { std::cout << "Usage:\n" - "\tkatja {info|help} [OPTIONS]\n\n"; + "\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"); } command_exception::command_exception(const command_exception_t exception_type, @@ -65,6 +92,10 @@ namespace katja { return std::make_unique<list>(); } + else if (strcmp(argv[1], "update") == 0) + { + return std::make_unique<update>(); + } else if (strcmp(argv[1], "help") == 0) { return std::make_unique<help>(); |
