diff --git a/src/database.cpp b/src/database.cpp index 77a3414..8225abd 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -39,7 +39,7 @@ void Database::deleteAccount(const std::string &account, sqlite3 *db) { rc = sqlite3_step(stmt); sqlite3_finalize(stmt); - + if (rc != SQLITE_DONE) throw std::runtime_error("Failed to delete account " + account); } @@ -108,7 +108,7 @@ double Database::cacheAccountValue(long long accountId, sqlite3 *db) { throw std::runtime_error("Failed to set cashedValue for " + std::to_string(accountId)); } -void Database::accountDescription(const std::string& account, const std::string& description, sqlite3 *db) { +void Database::accountDescription(const std::string &account, const std::string &description, sqlite3 *db) { sqlite3_stmt *stmt; int rc = sqlite3_prepare_v2(db, "UPDATE account SET description = ? WHERE name = ?", -1, &stmt, nullptr); diff --git a/src/optHandlers/mainOptHandler.cpp b/src/optHandlers/mainOptHandler.cpp index 0c8d79b..3aa14f5 100644 --- a/src/optHandlers/mainOptHandler.cpp +++ b/src/optHandlers/mainOptHandler.cpp @@ -64,7 +64,7 @@ void MainOptHandler::accountOptHandler(std::string account) { {"delete", no_argument, nullptr, 'd'}, {"force-delete", no_argument, nullptr, 'F'}, {"value", no_argument, nullptr, 'v'}, - {"description", required_argument, nullptr, 'D'}, + {"description", required_argument, nullptr, 'D'}, }; auto acctOperation = std::make_unique(db, account); @@ -293,40 +293,39 @@ void MainOptHandler::paymentOptHandler(std::string account) { } void MainOptHandler::help() { - std::cout << "Output of budget." << std::endl; - std::cout << "Usage:" << std::endl; - std::cout << "\tbudget [options] ..." << std::endl; - std::cout << "Actions:" << std::endl; - std::cout << "\t-h --help Prints this." << std::endl; - std::cout << "\t-a --account<=STRING> Management tools for an account." << std::endl; - std::cout << "\t-c --create<=STRING> Creates a new account with NAME." << std::endl; - std::cout << "\t-e --earn<=STRING> Add an earning to an account." << std::endl; - std::cout << "\t-p --payment<=STRING> Add a payment to an account." << std::endl; - std::cout << "Account Options: [-dvD]" << std::endl; - std::cout << "\t-d --delete Deletes specified account." << std::endl; - std::cout << "\t--force-delete Deletes the specified account without confirmation." << std::endl; - std::cout << "\t-v --value Gets the current value of the account." << std::endl; - std::cout << "\t-D --description<=STRING> Changes the description of the account." << std::endl; - std::cout << "Create Options: [-d]" << std::endl; - std::cout << "\t-d --description<=STRING> Sets a description for an account." << std::endl; - std::cout << "Earn Options: -v [-drD]" << std::endl; - std::cout << "\t-v --value= Value for earning." << std::endl; - std::cout << "\t-d --description= Description for earning." << std::endl; - std::cout << "\t-r --receipt= Path to file to store in DB as receipt." << std::endl; - std::cout << "\t-D --date= Date as dd/mm/yyyyTHH:MM:SS. Default will be today." << std::endl; - std::cout << "Payment Options: -v [-drD]" << std::endl; - std::cout << "\t-v --value= Value for payment." << std::endl; - std::cout << "\t-d --description= Description for payment." << std::endl; - std::cout << "\t-r --receipt= Path to file to store in DB as receipt." << std::endl; - std::cout << "\t-D --date= Date as dd/mm/yyyyTHH:MM:SS. Default will be today." << std::endl; - std::cout << std::endl; - std::cout << "Arguments are processed like blocks with each one terminated by the next Action. For example" - << std::endl; - std::cout << std::endl; - std::cout << R"(budget -cAcct -eAcct -v10.00 -r"./receipt.pdf" -pAcct -v5.50 -r"./payment.pdf")" << std::endl; - std::cout << std::endl; - std::cout << "Does the following in order:" << std::endl; - std::cout << "Creates an account named Acct with no description." << std::endl; - std::cout << "Earns 10.00 to it with a receipt." << std::endl; - std::cout << "Pays 5.50 to it with a receipt." << std::endl; + std::cout << "Output of budget.\n" + "Usage:\n" + " budget [options] ...\n" + "Actions:\n" + " -h --help Prints this.\n" + " -a --account<=STRING> Management tools for an account.\n" + " -c --create<=STRING> Creates a new account with NAME.\n" + " -e --earn<=STRING> Add an earning to an account.\n" + " -p --payment<=STRING> Add a payment to an account.\n" + "Account Options: [-dvD]\n" + " -d --delete Deletes specified account.\n" + " --force-delete Deletes the specified account without confirmation.\n" + " -v --value Gets the current value of the account.\n" + " -D --description<=STRING> Changes the description of the account.\n" + "Create Options: [-d]\n" + " -d --description<=STRING> Sets a description for an account.\n" + "Earn Options: -v [-drD]\n" + " -v --value= Value for earning.\n" + " -d --description= Description for earning.\n" + " -r --receipt= Path to file to store in DB as receipt.\n" + " -D --date= Date as dd/mm/yyyyTHH:MM:SS. Default will be today.\n" + "Payment Options: -v [-drD]\n" + " -v --value= Value for payment.\n" + " -d --description= Description for payment.\n" + " -r --receipt= Path to file to store in DB as receipt.\n" + " -D --date= Date as dd/mm/yyyyTHH:MM:SS. Default will be today.\n" + "\n" + "Arguments are processed like blocks with each one terminated by the next Action. For example\n" + "\n" + "budget -cAcct -eAcct -v10.00 -r\"./receipt.pdf\" -pAcct -v5.50 -r\"./payment.pdf\"\n" + "\n" + "Does the following in order:\n" + "Creates an account named Acct with no description.\n" + "Earns 10.00 to it with a receipt.\n" + "Pays 5.50 to it with a receipt." << std::endl; } diff --git a/src/sqliteDb.h b/src/sqliteDb.h index 352e632..9e41761 100644 --- a/src/sqliteDb.h +++ b/src/sqliteDb.h @@ -9,16 +9,18 @@ class SqliteDb { public: - explicit SqliteDb(sqlite3* db) : m_db(db) {} + explicit SqliteDb(sqlite3 *db) : m_db(db) {} ~SqliteDb() { sqlite3_close(m_db); } - explicit operator sqlite3*() { + + explicit operator sqlite3 *() { return m_db; } + private: - sqlite3* m_db; + sqlite3 *m_db; }; #endif //BUDGET_SQLITEDB_H