2022-08-04 18:22:48 -05:00
|
|
|
//
|
|
|
|
// Created by quentin on 8/3/22.
|
|
|
|
//
|
|
|
|
|
2022-08-12 15:26:25 -05:00
|
|
|
#include "main.h"
|
|
|
|
#include "data/accountData.h"
|
2022-08-13 16:35:01 -05:00
|
|
|
#include "optHandlers/accountOptHandler.h"
|
2022-08-04 18:22:48 -05:00
|
|
|
|
2022-08-12 15:26:25 -05:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <list>
|
2022-08-13 16:35:01 -05:00
|
|
|
#include <getopt.h>
|
|
|
|
|
|
|
|
using namespace Budget;
|
2022-08-12 15:26:25 -05:00
|
|
|
|
|
|
|
const std::string homeDirectory = getpwuid(getuid())->pw_dir;
|
|
|
|
|
|
|
|
void createRequiredFolders() {
|
|
|
|
std::filesystem::create_directory(homeDirectory + "/.config/budget/");
|
|
|
|
std::filesystem::create_directories(homeDirectory + "/.local/share/budget");
|
|
|
|
std::filesystem::create_directories(homeDirectory + "/.local/share/budget/accounts");
|
2022-08-12 16:54:11 -05:00
|
|
|
std::filesystem::create_directories(homeDirectory + "/.local/share/budget/receipts");
|
2022-08-12 15:26:25 -05:00
|
|
|
}
|
|
|
|
|
2022-08-13 16:35:01 -05:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
std::vector<char *> args(argv, argv + argc);
|
|
|
|
|
|
|
|
OptHandlers::AccountOptHandler accountOptHandler(args);
|
|
|
|
accountOptHandler.parse();
|
|
|
|
|
2022-08-12 15:26:25 -05:00
|
|
|
createRequiredFolders();
|
2022-08-13 16:35:01 -05:00
|
|
|
// Read all accounts saved and store them in accounts
|
2022-08-12 15:26:25 -05:00
|
|
|
std::list<AccountData> accounts;
|
|
|
|
for (const auto &file : std::filesystem::directory_iterator(
|
|
|
|
homeDirectory + "/.local/share/budget/accounts")) {
|
|
|
|
accounts.emplace_back(AccountData(file.path()));
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|