Run pre-commit on files

This commit is contained in:
realaltffour 2020-04-05 14:54:23 +03:00
parent 5eae19af68
commit 63ad0d6ba1
No known key found for this signature in database
GPG Key ID: 05B35E2E8F56C5A6
12 changed files with 18761 additions and 19678 deletions

View File

@ -1,11 +1,7 @@
#include "data.h"
void to_json(json& j, const Date& date) {
j = json{
{"day", date.day},
{"month", date.day},
{"year", date.year}
};
j = json{{"day", date.day}, {"month", date.day}, {"year", date.year}};
}
void from_json(const json& j, Date& date) {
j.at("day").get_to(date.day);
@ -13,15 +9,13 @@ void from_json(const json& j, Date& date) {
j.at("year").get_to(date.year);
}
void to_json(json& j, const Project& proj) {
j = json{
{"name", proj.name},
j = json{{"name", proj.name},
{"desc", proj.desc},
{"uuid", proj.uuid},
{"pri", proj.pri},
{"creationDate", proj.creationDate},
{"doneDate", proj.doneDate},
{"isDone", proj.isDone}
};
{"isDone", proj.isDone}};
}
void from_json(const json& j, Project& proj) {
j.at("name").get_to(proj.name);
@ -43,11 +37,9 @@ void from_json(const json& j, Skid& skid) {
j.at("creationDate").get_to(skid.creationDate);
}
void to_json(json& j, const DB& db) {
j = json{
{"projects", *db.projects},
j = json{{"projects", *db.projects},
{"creationDate", db.creationDate},
{"lastAccessTime", db.lastAccessTime}
};
{"lastAccessTime", db.lastAccessTime}};
}
void from_json(const json& j, DB& db) {
j.at("projects").get_to(*db.projects);
@ -55,26 +47,25 @@ void from_json(const json& j, DB& db) {
j.at("lastAccessTime").get_to(db.lastAccessTime);
}
void writeDB(DB db, const std::string &dest) {
void writeDB(DB db, const std::string& dest) {
try {
std::ofstream f(dest);
json j = db;
std::cout << "hello" << std::endl;
f << j;
} catch (std::exception &ex) {
} catch(std::exception& ex) {
std::cout << "Failed writing database to: " << dest << std::endl;
std::cout << "Error: " << ex.what() << std::endl;
}
}
void loadDB(DB &db, const std::string &src) {
void loadDB(DB& db, const std::string& src) {
try {
std::ifstream f(src);
json j;
f >> j;
db = j;
} catch (const std::exception& ex) {
} catch(const std::exception& ex) {
std::cout << "Failed loading database from: " << src << std::endl;
std::cout << "Error: " << ex.what() << std::endl;
}

View File

@ -33,7 +33,7 @@ struct Project {
};
struct Skid {
std::vector<Project> *projects = {};
std::vector<Project>* projects = {};
Date creationDate;
};
@ -50,7 +50,7 @@ struct Event {
};
struct EventLog {
std::vector<Event> *events;
std::vector<Event>* events;
std::string sha512 = "";
};
@ -58,7 +58,7 @@ struct EventLog {
// Main Database that represents the skidjular directory.
struct DB {
std::map<std::string, Project> *projects;
std::map<std::string, Project>* projects;
std::vector<Skid> skids;
EventLog log;
@ -68,8 +68,8 @@ struct DB {
////////////// Utilities for the Database structure ////////////////
void writeDB(DB db, const std::string &dest);
void loadDB(DB &db, const std::string &src);
void writeDB(DB db, const std::string& dest);
void loadDB(DB& db, const std::string& src);
////////////// End Utilities for the Database structure ////////////

View File

@ -7,8 +7,10 @@
#include "module.h"
#include "modules/init.h"
Module* get_Mod(std::string name) {return nullptr;};
void dispatch_Mod(Module* mod, std::string args) {};
Module* get_Mod(std::string name) {
return nullptr;
};
void dispatch_Mod(Module* mod, std::string args){};
int main(int argc, const char* argv[]) {
using namespace boost::program_options;
@ -33,36 +35,35 @@ int main(int argc, const char* argv[]) {
vm);
notify(vm);
if (vm.count("help")) {
if(vm.count("help")) {
std::cout << general << "\n";
exit(0);
} else if (vm.count("help-module")) {
} else if(vm.count("help-module")) {
auto name = vm["help-module"].as<string>();
auto module = get_Mod(name);
if (!module) {
if(!module) {
std::cout << "Module not found.\n";
exit(1);
}
std::cout << module->desc << "\n";
} else if (vm.count("module")) {
} else if(vm.count("module")) {
auto name = vm["module"].as<string>();
auto module = get_Mod(name);
if (!module) {
if(!module) {
std::cout << "Module not found.\n";
exit(1);
}
if (vm.count("module-args")) {
if(vm.count("module-args")) {
auto args = vm["module-args"].as<string>();
dispatch_Mod(module, args);
} else dispatch_Mod(module, "");
} else
dispatch_Mod(module, "");
} else {
std::cout << general << "\n";
exit(0);
}
} catch (const error& ex) {
cerr << ex.what() << '\n';
}
} catch(const error& ex) { cerr << ex.what() << '\n'; }
return 0;
}

View File

@ -6,7 +6,7 @@ void init_create(init_args arg) {
std::cout << "Creating database in current directory." << std::endl;
DB db;
time_t t = time(0);
struct tm *currentTime = localtime(&t);
struct tm* currentTime = localtime(&t);
db.creationDate.day = currentTime->tm_mday;
db.creationDate.month = currentTime->tm_mon;

12031
vendor/json.hpp vendored

File diff suppressed because it is too large Load Diff