save/load commands
This commit is contained in:
parent
f626151345
commit
a48d1cf88d
@ -114,7 +114,7 @@ public:
|
|||||||
{
|
{
|
||||||
//if (next < min) next = min;
|
//if (next < min) next = min;
|
||||||
//if (next > max) next = max;
|
//if (next > max) next = max;
|
||||||
if (next != value)
|
if (next != value || string.empty())
|
||||||
{
|
{
|
||||||
this->fireCallbacks(next);
|
this->fireCallbacks(next);
|
||||||
value = next;
|
value = next;
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#include <core/cvwrapper.hpp>
|
#include <core/cvwrapper.hpp>
|
||||||
#include <settings/Manager.hpp>
|
#include <settings/Manager.hpp>
|
||||||
#include <init.hpp>
|
#include <init.hpp>
|
||||||
|
#include <settings/SettingsIO.hpp>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Created on 29.07.18.
|
Created on 29.07.18.
|
||||||
@ -44,6 +48,38 @@ static CatCommand cat("cat", "", [](const CCommand& args) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static CatCommand save("save", "", [](const CCommand& args) {
|
||||||
|
settings::SettingsWriter writer{ settings::Manager::instance() };
|
||||||
|
|
||||||
|
DIR *config_directory = opendir(DATA_PATH "/configs");
|
||||||
|
if (!config_directory)
|
||||||
|
{
|
||||||
|
logging::Info("Configs directory doesn't exist, creating one!");
|
||||||
|
mkdir(DATA_PATH "/configs", S_IRWXU | S_IRWXG);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.ArgC() == 1)
|
||||||
|
{
|
||||||
|
writer.saveTo(DATA_PATH "/configs/default.conf", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
writer.saveTo(std::string(DATA_PATH "/configs/") + args.Arg(1) + ".conf", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
static CatCommand load("load", "", [](const CCommand& args) {
|
||||||
|
settings::SettingsReader loader{ settings::Manager::instance() };
|
||||||
|
if (args.ArgC() == 1)
|
||||||
|
{
|
||||||
|
loader.loadFrom(DATA_PATH "/configs/default.conf");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loader.loadFrom(std::string(DATA_PATH "/configs/") + args.Arg(1) + ".conf");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
static std::vector<std::string> sorted{};
|
static std::vector<std::string> sorted{};
|
||||||
|
|
||||||
static void getAndSortAllVariables()
|
static void getAndSortAllVariables()
|
||||||
|
Reference in New Issue
Block a user