Code cleanup

This commit is contained in:
quentin 2022-09-06 17:04:06 -05:00
parent 53ba7c9cc9
commit c2ada74e6b
4 changed files with 7 additions and 6 deletions

View File

@ -26,6 +26,7 @@ public:
void flushToFile(); void flushToFile();
void deleteObject(); void deleteObject();
private: private:
const std::string fileName; const std::string fileName;
const std::string homeDirectory = getpwuid(getuid())->pw_dir; const std::string homeDirectory = getpwuid(getuid())->pw_dir;

View File

@ -26,8 +26,7 @@ Data<T>::Data(std::string file) : fileName(std::move(file)) {
document.Parse(std::string(bytes.data(), fileSize).c_str()); document.Parse(std::string(bytes.data(), fileSize).c_str());
chkExistIfs.close(); chkExistIfs.close();
} } else {
else {
// File doesnt exist we need to create one // File doesnt exist we need to create one
// This is the job of the derives constructor. // This is the job of the derives constructor.
chkExistIfs.close(); chkExistIfs.close();

View File

@ -55,7 +55,8 @@ int main(int argc, char *argv[]) {
accountOptHandler.help(); accountOptHandler.help();
} }
if (accountOptHandler.getSetOpts()->create) { if (accountOptHandler.getSetOpts()->create) {
accounts.emplace_back(storageD + "accounts/" + accountOptHandler.getSetOpts()->createAccount + ".json", accountOptHandler.getSetOpts()->createAccount); accounts.emplace_back(storageD + "accounts/" + accountOptHandler.getSetOpts()->createAccount + ".json",
accountOptHandler.getSetOpts()->createAccount);
} }
} }
return 0; return 0;

View File

@ -10,11 +10,11 @@ using namespace Budget::OptHandlers;
void AccountOptHandler::parse() { void AccountOptHandler::parse() {
struct option longOpts[] = { struct option longOpts[] = {
{"help", no_argument, nullptr, 'h'}, {"help", no_argument, nullptr, 'h'},
{"list", no_argument, nullptr, 'l'}, {"list", no_argument, nullptr, 'l'},
{"delete", required_argument, nullptr, 'd'}, {"delete", required_argument, nullptr, 'd'},
{"create", required_argument, nullptr, 'c'}, {"create", required_argument, nullptr, 'c'},
{"value", required_argument, nullptr, 'v'}, {"value", required_argument, nullptr, 'v'},
}; };
while (true) { while (true) {