Browse Source

Manager: Switch from Util to the ruc library

master
Riyyi 2 years ago
parent
commit
4927e35bfc
  1. 14
      src/config.cpp
  2. 10
      src/config.h
  3. 6
      src/dotfile.cpp
  4. 4
      src/dotfile.h
  5. 4
      src/machine.cpp
  6. 4
      src/machine.h
  7. 10
      src/main.cpp
  8. 16
      src/package.cpp
  9. 4
      src/package.h

14
src/config.cpp

@ -12,8 +12,8 @@
#include <vector>
#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);

10
src/config.h

@ -11,8 +11,8 @@
#include <string>
#include <vector>
#include "util/json/json.h"
#include "util/singleton.h"
#include "ruc/json/json.h"
#include "ruc/singleton.h"
struct Settings {
std::vector<std::string> ignorePatterns {
@ -31,7 +31,7 @@ struct Settings {
};
};
class Config : public Util::Singleton<Config> {
class Config : public ruc::Singleton<Config> {
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);

6
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=",

4
src/dotfile.h

@ -13,9 +13,9 @@
#include <string>
#include <vector>
#include "util/singleton.h"
#include "ruc/singleton.h"
class Dotfile : public Util::Singleton<Dotfile> {
class Dotfile : public ruc::Singleton<Dotfile> {
public:
Dotfile(s);
virtual ~Dotfile();

4
src/machine.cpp

@ -9,7 +9,7 @@
#include <unistd.h> // 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) {

4
src/machine.h

@ -10,9 +10,9 @@
#include <pwd.h> // passwd
#include <string>
#include "util/singleton.h"
#include "ruc/singleton.h"
class Machine : public Util::Singleton<Machine> {
class Machine : public ruc::Singleton<Machine> {
public:
Machine(s);
virtual ~Machine();

10
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<std::string> 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);

16
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<std::string> 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");

4
src/package.h

@ -11,9 +11,9 @@
#include <string>
#include <vector>
#include "util/singleton.h"
#include "ruc/singleton.h"
class Package : public Util::Singleton<Package> {
class Package : public ruc::Singleton<Package> {
public:
Package(s);
virtual ~Package();

Loading…
Cancel
Save