rcc/CLAUDE.md

2.1 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Commands

cargo build            # debug build
cargo build --release  # release build
cargo run -- <args>    # run with args (see CLI section)
cargo check            # fast type/borrow check without linking
cargo clippy           # lint

No tests exist yet in this project.

Configuration

The binary reads environment config from ~/.config/rcc/<env> (dotenv format). Default env is local.

Required keys: DB_USERNAME, DB_PASSWORD Optional keys: DB_LOCATION (default: localhost), DB_PORT (default: 3306), DB (default: efulfilment)

Pass -e <env> to select a config file (e.g., -e stage loads ~/.config/rcc/stage).

Architecture

Three-layer structure: CLI → Service → Repository, wired together in container.rs.

  • src/cli/command.rs — Clap structs defining all subcommands (Merch, Schema, Filter, Page, Job, Use)
  • src/cli/controller.rs — dispatches parsed args to the appropriate service
  • src/container.rs — factory functions that construct Repo → Service pairs from a Db instance
  • src/database/db.rsDb wraps a Arc<Mutex<Pool>> (mysql); Db::initialize(env) loads the dotenv config and opens a connection pool
  • src/repository/ — one repo per domain entity; each holds a Db and executes raw MySQL queries
  • src/service/ — one service per domain; holds the corresponding repo, formats and prints results to stdout
  • src/entity/ — plain structs with mysql::FromRow derives representing DB rows
  • src/lib.rs — exports the TerminalSize trait (used by services to adapt output width to the terminal)

CLI Usage

rcc [-e <env>] <subcommand>

merch <search>              # search merchants by name
schema <search>             # list columns for a table
filter <id> [-a] [-c] [-l]  # filter info; -a=all, -c=config, -l=log
page <id>                   # page/file info
job <id> [-l]               # job info; -l=log
use <file_name>             # find filters that use a given file/module