From 4927e35bfc4877c569e1cc8e806490559c583eca Mon Sep 17 00:00:00 2001 From: Riyyi Date: Tue, 13 Sep 2022 10:52:36 +0200 Subject: [PATCH] Manager: Switch from Util to the ruc library --- src/config.cpp | 14 +++++++------- src/config.h | 10 +++++----- src/dotfile.cpp | 6 +++--- src/dotfile.h | 4 ++-- src/machine.cpp | 4 ++-- src/machine.h | 4 ++-- src/main.cpp | 12 ++++++------ src/package.cpp | 16 ++++++++-------- src/package.h | 4 ++-- 9 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index de99f88..8b56256 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -12,8 +12,8 @@ #include #include "config.h" -#include "util/json/json.h" -#include "util/meta/assert.h" +#include "ruc/json/json.h" +#include "ruc/meta/assert.h" Config::Config(s) : m_workingDirectory(std::filesystem::current_path()) @@ -51,7 +51,7 @@ void Config::parseConfigFile() return; } - Util::Json json; + ruc::Json json; std::ifstream file(m_config); if (!file.is_open()) { @@ -72,17 +72,17 @@ void Config::parseConfigFile() // ----------------------------------------- -void toJson(Util::Json& json, const Settings& settings) +void toJson(ruc::Json& json, const Settings& settings) { - json = Util::Json { + json = ruc::Json { { "ignorePatterns", settings.ignorePatterns }, { "systemPatterns", settings.systemPatterns } }; } -void fromJson(const Util::Json& json, Settings& settings) +void fromJson(const ruc::Json& json, Settings& settings) { - VERIFY(json.type() == Util::Json::Type::Object); + VERIFY(json.type() == ruc::Json::Type::Object); if (json.exists("ignorePatterns")) { json.at("ignorePatterns").getTo(settings.ignorePatterns); diff --git a/src/config.h b/src/config.h index a0bc788..c87236c 100644 --- a/src/config.h +++ b/src/config.h @@ -11,8 +11,8 @@ #include #include -#include "util/json/json.h" -#include "util/singleton.h" +#include "ruc/json/json.h" +#include "ruc/singleton.h" struct Settings { std::vector ignorePatterns { @@ -31,7 +31,7 @@ struct Settings { }; }; -class Config : public Util::Singleton { +class Config : public ruc::Singleton { public: Config(s); virtual ~Config(); @@ -65,5 +65,5 @@ private: // Json arbitrary type conversion functions -void toJson(Util::Json& object, const Settings& settings); -void fromJson(const Util::Json& object, Settings& settings); +void toJson(ruc::Json& object, const Settings& settings); +void fromJson(const ruc::Json& object, Settings& settings); diff --git a/src/dotfile.cpp b/src/dotfile.cpp index 2bff386..35c2fac 100644 --- a/src/dotfile.cpp +++ b/src/dotfile.cpp @@ -18,8 +18,8 @@ #include "config.h" #include "dotfile.h" #include "machine.h" -#include "util/file.h" -#include "util/meta/assert.h" +#include "ruc/file.h" +#include "ruc/meta/assert.h" Dotfile::Dotfile(s) { @@ -373,7 +373,7 @@ void Dotfile::sync(SyncType type, void Dotfile::selectivelyCommentOrUncomment(const std::string& path) { - Util::File dotfile(path); + ruc::File dotfile(path); const std::string search[3] = { "distro=", diff --git a/src/dotfile.h b/src/dotfile.h index 3373444..1022f06 100644 --- a/src/dotfile.h +++ b/src/dotfile.h @@ -13,9 +13,9 @@ #include #include -#include "util/singleton.h" +#include "ruc/singleton.h" -class Dotfile : public Util::Singleton { +class Dotfile : public ruc::Singleton { public: Dotfile(s); virtual ~Dotfile(); diff --git a/src/machine.cpp b/src/machine.cpp index 2068580..6195b79 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -9,7 +9,7 @@ #include // gethostname, getlogin #include "machine.h" -#include "util/file.h" +#include "ruc/file.h" Machine::Machine(s) { @@ -26,7 +26,7 @@ Machine::~Machine() void Machine::fetchDistro() { - Util::File osRelease("/etc/os-release"); + ruc::File osRelease("/etc/os-release"); std::istringstream stream(osRelease.data()); for (std::string line; std::getline(stream, line);) { if (line.find("ID=") == 0) { diff --git a/src/machine.h b/src/machine.h index f0a669f..1381599 100644 --- a/src/machine.h +++ b/src/machine.h @@ -10,9 +10,9 @@ #include // passwd #include -#include "util/singleton.h" +#include "ruc/singleton.h" -class Machine : public Util::Singleton { +class Machine : public ruc::Singleton { public: Machine(s); virtual ~Machine(); diff --git a/src/main.cpp b/src/main.cpp index 893d90d..cf6392f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,8 +11,8 @@ #include "config.h" #include "dotfile.h" #include "package.h" -#include "util/argparser.h" -#include "util/timer.h" +#include "ruc/argparser.h" +#include "ruc/timer.h" int main(int argc, const char* argv[]) { @@ -28,7 +28,7 @@ int main(int argc, const char* argv[]) std::vector targets {}; - Util::ArgParser argParser; + ruc::ArgParser argParser; argParser.addOption(fileOperation, 'F', "file", nullptr, nullptr); argParser.addOption(packageOperation, 'P', "package", nullptr, nullptr); argParser.addOption(helpOperation, 'h', "help", nullptr, nullptr); @@ -39,7 +39,7 @@ int main(int argc, const char* argv[]) argParser.addOption(pushOrStore, 's', "push", nullptr, nullptr); argParser.addOption(verbose, 'v', "verbose", nullptr, nullptr); - argParser.addArgument(targets, "targets", nullptr, nullptr, Util::ArgParser::Required::No); + argParser.addArgument(targets, "targets", nullptr, nullptr, ruc::ArgParser::Required::No); argParser.parse(argc, argv); if (fileOperation + packageOperation + helpOperation > 1) { @@ -48,7 +48,7 @@ int main(int argc, const char* argv[]) } #ifndef NDEBUG - Util::Timer t; + ruc::Timer t; #endif Config::the().setVerbose(verbose); @@ -89,7 +89,7 @@ int main(int argc, const char* argv[]) } #ifndef NDEBUG - printf("%fms\n", t.elapsedNanoseconds() / 1000000.0); + printf("%fms\n", t.elapsedNanoseconds() / 1000000.0); #endif return 0; diff --git a/src/package.cpp b/src/package.cpp index 7e7f065..dd0a591 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -16,9 +16,9 @@ #include "machine.h" #include "package.h" -#include "util/file.h" -#include "util/shell.h" -#include "util/system.h" +#include "ruc/file.h" +#include "ruc/shell.h" +#include "ruc/system.h" Package::Package(s) { @@ -80,7 +80,7 @@ void Package::store() return; } - auto packageFile = Util::File::create("./packages"); + auto packageFile = ruc::File::create("./packages"); packageFile.clear(); packageFile.append(packagesOrEmpty.value()); packageFile.flush(); @@ -126,15 +126,15 @@ void Package::installOrAurInstall(InstallType type) std::string command = ""; - Util::System $; + ruc::System $; if (m_distro == Distro::Arch) { // Grab everything off enabled official repositories that is in the list auto repoList = $("pacman -Ssq") | $("grep -xf ./packages"); if (type == InstallType::AurInstall) { // Determine which packages in the list are from the AUR - // NOTE: Util::System does not support commands with newlines - auto aurList = Util::Shell()("grep -vx '" + repoList.output() + "' ./packages"); + // NOTE: ruc::System does not support commands with newlines + auto aurList = ruc::Shell()("grep -vx '" + repoList.output() + "' ./packages"); command = aurHelper.value() + " -Sy --devel --needed --noconfirm " + aurList.output(); } else { @@ -224,7 +224,7 @@ std::optional Package::getPackageList() std::string packages; - Util::System $; + ruc::System $; if (m_distro == Distro::Arch) { auto basePackages = $("pactree -u base").tail(2, true); auto develPackages = $("pacman -Qqg base-devel"); diff --git a/src/package.h b/src/package.h index 6f6abd4..28aaabb 100644 --- a/src/package.h +++ b/src/package.h @@ -11,9 +11,9 @@ #include #include -#include "util/singleton.h" +#include "ruc/singleton.h" -class Package : public Util::Singleton { +class Package : public ruc::Singleton { public: Package(s); virtual ~Package();