CLI Reading Log
Build a command-line reading log in Ruby. You record books and reading sessions from the terminal, for example: reading add-book "Dune" --pages 412, then reading log "Dune" 35 to record 35 pages read today, and reading report to see how many pages you read each month and how far along each book is. Data is stored in a small SQLite database through ActiveRecord, the database library from Rails, used here on its own without a web app. It's a friendly first Ruby project: you'll learn classes and methods, gems and Bundler, command-line arguments, validations, and working with dates.
- Estimate
- ~8.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Rails · RubyGems
Project roadmap
- 01
Set up the project with Bundler
~1hInstall Ruby and create a project folder with bundle init. Add the gems activerecord and sqlite3 to the Gemfile and run bundle install. Create bin/reading as an executable Ruby script that prints the available commands when run without arguments. Done when: bin/reading prints the command list.
- 02
Create the database with ActiveRecord
~1.5hConnect ActiveRecord to a SQLite file (reading_log.sqlite3) and create two tables with ActiveRecord::Schema.define: books (title, author, total_pages) and sessions (book_id, pages, read_on date). Create the Book and ReadingSession models with has_many and belongs_to. Done when: running the script creates the database file with both tables.
- 03
Add books
~1.5hImplement add-book TITLE --pages N [--author NAME]. Add model validations: a title is required and unique, and total_pages is a whole number above 0. When a validation fails, print its error messages instead of crashing. Implement books, which lists every book with its progress. Done when: adding a book works, and adding it again or with --pages 0 prints a clear error.
- 04
Log reading sessions
~1.5hImplement log TITLE PAGES [--date YYYY-MM-DD], which records the pages read on that date (today by default). Validate that the book exists, pages is above 0, the date is valid and not in the future, and the total pages logged don't exceed the book's length. Done when: logging pages updates the book's progress in the books list.
- 05
Print the monthly report
~1.5hImplement report [--year YYYY], which prints the total pages read for each month of the year, the busiest month, and the books finished that year. Format it as an aligned table, and show a message when there's no data yet. Done when: after logging sessions over several months, the report shows correct monthly totals.
- 06
Write tests
~1.5hAdd minitest (or RSpec) tests that use an in-memory SQLite database: validations, logging more pages than the book has, the monthly totals, and finished books. Add a Rakefile so rake test runs them. Done when: rake test passes.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack