Skip to content

breakingthebot/library-catalog-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Library Catalog

Java command-line library catalog that models books and members, supports interactive checkout commands, and persists catalog state to a flat file.

Stack

  • Java 21+ compatible source level
  • Maven
  • JUnit 5
  • Executable jar packaging via Maven JAR Plugin

Setup

  1. Install JDK 21 or a compatible newer JDK.
  2. Clone the repository.
  3. Open a terminal in the project root.
  4. Use the committed Maven wrapper scripts instead of requiring a separate Maven install.

Environment Variables

This project currently requires no environment variables. See .env.example.

Running Locally

Run the Maven test suite:

.\mvnw.cmd test

Build the executable jar:

.\mvnw.cmd -q package

Run the CLI help:

java -jar target/library-catalog.jar help

Print the packaged application version:

java -jar target/library-catalog.jar --version

Invalid commands now return a stable non-zero exit code with a user-facing error message instead of a raw stack trace.

Bootstrap a missing catalog with sample data only on first run:

java -jar target/library-catalog.jar bootstrap --data temp-catalog.txt

Seed a new catalog:

java -jar target/library-catalog.jar seed

Add a book and member:

java -jar target/library-catalog.jar add-book book-010 "Domain-Driven Design" "Eric Evans"
java -jar target/library-catalog.jar add-member member-010 "Jamie Cross"

Remove an available book or an idle member:

java -jar target/library-catalog.jar remove-book book-010
java -jar target/library-catalog.jar remove-member member-010

Checkout and inspect the catalog:

java -jar target/library-catalog.jar checkout book-010 member-010
java -jar target/library-catalog.jar list-books
java -jar target/library-catalog.jar list-members
java -jar target/library-catalog.jar find-book "domain"
java -jar target/library-catalog.jar find-member "jamie"
java -jar target/library-catalog.jar loan-report
java -jar target/library-catalog.jar overdue-report

CI

GitHub Actions runs ./mvnw -q package on every push to main and every pull request targeting main.

Deployed

Not deployed. This is a local Java command-line project.

Architecture Notes

This build now uses a conventional Maven project layout instead of an ad hoc compile script and custom test runner. The application code lives under src/main/java, the tests live under src/test/java, and JUnit 5 now drives the test suite. On top of that, the Maven build now produces a runnable jar, so the project is no longer just source you can build; it is a CLI artifact you can package and launch directly with java -jar. The internal Java packages now use a real namespace, com.breakingthebot.librarycatalog, which makes the codebase look and behave like a conventional Java project instead of a temporary scaffold. This iteration also moves the checkout flow closer to a real lending system by assigning a default 14-day due date on checkout, persisting that date with the catalog, and exposing a dedicated overdue report so the CLI can separate active loans from late ones.

Notes

  • The project now uses Maven with JUnit 5 instead of the earlier custom test harness.
  • The default catalog file is data/library-catalog.txt.
  • Any command can target a different file with --data <path>.
  • Commands currently supported: help, version, --version, bootstrap, seed, add-book, add-member, remove-book, remove-member, checkout, return, list-books, list-members, find-book, find-member, loan-report, and overdue-report.
  • Continuous integration lives in .github/workflows/java-ci.yml and runs ./mvnw -q package on JDK 21.
  • CLI boundary errors now return stable exit codes and clear messages with a help hint.
  • bootstrap seeds sample data only when the target catalog file does not already exist; it never overwrites an existing file.
  • checkout assigns a default due date 14 days from the checkout date.
  • loan-report now shows due dates and whether each active loan is overdue.
  • overdue-report only lists loans whose due dates are already in the past.
  • remove-book only works for available books, and remove-member only works for members with no active loans.
  • The primary distributable artifact is target/library-catalog.jar.
  • The code now uses the com.breakingthebot.librarycatalog package namespace across production and test code.
  • --version reads Maven metadata from the packaged artifact and prints the current application version.

Releases

Packages

Contributors

Languages