Skip to content

aliy112005/loan-tracker-cli

Repository files navigation

Overview

This is a complete, fully functioning implementation of the 371loans command-line application. The project strictly adheres to the C++14 standard and successfully passes all provided unit tests (testall) and output formatting tests (testoutputall) with a 100% success rate (384/384 assertions).

Implementation Details & "Known Caveats"

There are no known bugs, crashes, or memory leaks in this implementation. All requested functionality has been successfully implemented.

Here are a few specific design choices to note during marking:

  1. Type Safety in Date Class: The Date class implements year, month, and day as unsigned int rather than standard int. This intentional design choice prevents negative date logic and perfectly aligns with the provided Catch2 tests (e.g., test2.cpp), allowing the test suite to compile completely silently without -Wsign-compare warnings under the strict -Wall and -pedantic flags.

  2. Date Mathematics (14-Day Default): When creating an item without explicitly providing a --due date, the system defaults to adding 14 days to the borrowed date. To handle month and leap-year rollovers safely and accurately without relying on external third-party date libraries, the <ctime> standard library (struct tm and mktime()) was utilized.

  3. JSON Parsing (C++14 Compliance): To parse the database file, the nlohmann::json library is used. The loops iterating through the JSON objects were specifically written using C++14 iterator methods (e.g., element.key() and element.value()) rather than C++17 structured bindings to ensure the codebase remains strictly C++14 compliant.

  4. Error Handling (JSON vs. VALUE Actions): Edge cases where multiple invalid arguments are passed simultaneously (e.g., a valid item ID but a non-existent borrower email) are handled exactly according to the strict output expectations of testoutputall. The application prioritizes verifying the existence of the Borrower first before attempting to access or modify nested Item or Tag objects, throwing the exact required stderr output.

  5. Tag Parsing: The --tag argument gracefully handles comma-separated lists (e.g., tag1,tag2) by utilizing a std::stringstream to split the string and insert tags sequentially, ignoring duplicates.

Build Instructions

This project compiles perfectly using the provided scripts:

  • ./build.sh testall
  • ./build.sh testoutputall

About

A command-line loan and inventory tracking database built in C++14. Features complex object relationships, JSON serialization, and robust command-line argument parsing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages