This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
cargo build # Debug build
cargo build --release # Optimized release build
cargo run # Run debug target
cargo run --release # Run release target
cargo test # Run all unit tests
cargo clippy # Run linter
cargo fmt # Format codeMacfetch is a macOS-only Neofetch alternative written in Rust. It displays system information alongside an ASCII art logo.
src/main.rs: Entry point. Callsmacfetch::render()with the Darwin ASCII logo and a list of segment functions.src/macfetch/mod.rs: Contains therender()function that pairs ASCII logo lines with segment output lines.src/macfetch/segments/mod.rs: Individual segment functions (os, cpu, memory, etc.) that returnColoredString. Each segment fetches system data and formats it withtitled_segment().src/macfetch/ascii/mod.rs: ASCII art generation withgenerate_logo()that returns colored logo lines.src/macfetch/utils/: Helper modules for CLI handling, sysctl queries, host info, caching, and configuration.src/macfetch/utils/config.rs: TOML configuration loading. Maps segment names to functions and builds the segment list from~/.config/macfetch/config.toml.
- Segments are functions with signature
fn() -> ColoredStringpassed as a vector torender(). - System info is retrieved via
sysctlcrate, environment variables, and macOS-specific APIs (Core Graphics, Metal). - The
cachemodule providesfallback()for expensive operations (CPU/GPU lookups). - CLI args are handled via
clapinutils/cli.rswith derive-based parsing.
GitHub Actions runs on every push/PR to main:
cargo check- Compilationcargo test- Unit testscargo clippy -- -D warnings- Linter (warnings fail the build)cargo fmt --check- Formatting
- Create a new function in
src/macfetch/segments/mod.rsreturningColoredString - Use
titled_segment(name, value)for consistent formatting - Register the segment in
src/macfetch/utils/config.rs:- Add it to
segment_registry()HashMap - Add it to
default_segments()vector (if it should appear by default)
- Add it to