Skip to content

Workspace Architecture

Ken Tobias edited this page May 31, 2026 · 12 revisions

Workspace Architecture

retch is structured as a Cargo workspace to keep the codebase modular, clean, and reusable.

Repository Layout

.
├── Cargo.toml            # Root workspace config
├── Cargo.lock
├── Justfile              # Command runner scripts
├── README.md
├── docs/                 # Manual pages & documentation
├── src/                  # retch-cli source code
│   ├── cli.rs            # Clap arguments and flags
│   ├── config.rs         # TOML parsing & merge logic
│   ├── fetch.rs          # Parallel system info fetching
│   ├── main.rs           # Entry point and config creation
│   └── ...
└── crates/
    └── battery/          # retch-battery subcrate (standalone library)
        ├── Cargo.toml
        └── src/
            └── lib.rs    # Cross-platform battery implementation

Cargo Workspace

The root Cargo.toml specifies the workspace members:

[workspace]
members = [
    ".",
    "crates/battery",
]

1. retch-cli (Root Package)

The main binary command-line interface. It handles concurrent scoped threading, terminal detection, the configuration parsing engine, and formatting formatting to render output screens.

2. crates/battery (retch-battery)

A lightweight, standalone, zero-dependency library to query battery statistics on Linux, macOS, and Windows.

  • linux: Directly reads from /sys/class/power_supply/.
  • macos: Directly calls the native CoreFoundation IOPSCopyPowerSourcesInfo APIs.
  • windows: Invokes WMI queries via command utilities.
  • It operates with zero heavy dependencies (no nix or custom C bindings), making it extremely quick to build and safe to use.

Clone this wiki locally