|
|
@ -7,11 +7,31 @@ |
|
|
|
#ifndef CONFIG_H |
|
|
|
#ifndef CONFIG_H |
|
|
|
#define CONFIG_H |
|
|
|
#define CONFIG_H |
|
|
|
|
|
|
|
|
|
|
|
#include <cstddef> // size_t |
|
|
|
#include <cstddef> // size_t |
|
|
|
#include <filesystem> |
|
|
|
#include <filesystem> // path |
|
|
|
|
|
|
|
#include <map> |
|
|
|
|
|
|
|
#include <string> |
|
|
|
|
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "nlohmann/json.hpp" |
|
|
|
|
|
|
|
|
|
|
|
#include "util/singleton.h" |
|
|
|
#include "util/singleton.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Settings { |
|
|
|
|
|
|
|
std::map<std::string, std::string> excludePaths { |
|
|
|
|
|
|
|
{ ".git", "directory" }, |
|
|
|
|
|
|
|
{ ".md", "endsWith" }, |
|
|
|
|
|
|
|
{ "packages", "file" }, |
|
|
|
|
|
|
|
{ "README.org", "endsWith" }, |
|
|
|
|
|
|
|
{ "screenshot.png", "file" }, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
std::vector<std::filesystem::path> systemDirectories { |
|
|
|
|
|
|
|
"/boot", |
|
|
|
|
|
|
|
"/etc", |
|
|
|
|
|
|
|
"/usr/share" |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class Config : public Util::Singleton<Config> { |
|
|
|
class Config : public Util::Singleton<Config> { |
|
|
|
public: |
|
|
|
public: |
|
|
|
Config(s); |
|
|
|
Config(s); |
|
|
@ -19,12 +39,17 @@ public: |
|
|
|
|
|
|
|
|
|
|
|
void setVerbose(bool verbose) { m_verbose = verbose; } |
|
|
|
void setVerbose(bool verbose) { m_verbose = verbose; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const std::map<std::string, std::string>& excludePaths() const { return m_settings.excludePaths; } |
|
|
|
|
|
|
|
const std::vector<std::filesystem::path>& systemDirectories() const { return m_settings.systemDirectories; } |
|
|
|
|
|
|
|
|
|
|
|
const std::filesystem::path& workingDirectory() const { return m_workingDirectory; } |
|
|
|
const std::filesystem::path& workingDirectory() const { return m_workingDirectory; } |
|
|
|
size_t workingDirectorySize() const { return m_workingDirectorySize; } |
|
|
|
size_t workingDirectorySize() const { return m_workingDirectorySize; } |
|
|
|
|
|
|
|
|
|
|
|
bool verbose() const { return m_verbose; } |
|
|
|
bool verbose() const { return m_verbose; } |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
void findConfigFile(); |
|
|
|
void findConfigFile(); |
|
|
|
|
|
|
|
void parseConfigFile(); |
|
|
|
|
|
|
|
|
|
|
|
bool m_verbose { false }; |
|
|
|
bool m_verbose { false }; |
|
|
|
|
|
|
|
|
|
|
@ -32,6 +57,14 @@ private: |
|
|
|
size_t m_workingDirectorySize { 0 }; |
|
|
|
size_t m_workingDirectorySize { 0 }; |
|
|
|
|
|
|
|
|
|
|
|
std::filesystem::path m_config; |
|
|
|
std::filesystem::path m_config; |
|
|
|
|
|
|
|
Settings m_settings; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// nlohmann::json arbitrary type conversion functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void to_json(nlohmann::json& object, const Settings& settings); |
|
|
|
|
|
|
|
void from_json(const nlohmann::json& object, Settings& settings); |
|
|
|
|
|
|
|
|
|
|
|
#endif // CONFIG_H
|
|
|
|
#endif // CONFIG_H
|
|
|
|