This document provides AI agents with essential information about the rice codebase structure, architecture, and development guidelines.
Rice is a modern, configurable system information tool written in Rust, similar to neofetch. It displays system information alongside ASCII art in a horizontal layout with full customization support.
Key Features:
- Neofetch-style ASCII art + system info display
- TOML-based configuration system with customizable field colors
- Custom commands execution and display
- Cross-platform support (macOS, Linux, Windows)
- Colored blocks display (like neofetch)
- Legacy command compatibility
- JSON output support
src/
├── main.rs # CLI entry point, argument parsing
├── config/ # Configuration system
│ ├── mod.rs # Config structs (DisplayConfig, InfoConfig, AsciiArtConfig)
│ ├── defaults.rs # Default values and TOML generation
│ └── loader.rs # Config file loading/creation logic, custom config paths
├── display/ # Output rendering
│ ├── mod.rs # Main display logic, horizontal layout
│ ├── ascii_art.rs # ASCII art handling
│ ├── layout.rs # Layout system (minimal/unused)
│ └── themes.rs # Theming (minimal/unused)
├── info/ # System information collection
│ ├── mod.rs # InfoCollector trait and implementation, custom command integration
│ ├── system.rs # OS, hostname, kernel, uptime info
│ ├── hardware.rs # CPU, memory, disk info
│ ├── software.rs # Shell, terminal, packages, DE/WM info
│ ├── network.rs # Network info (minimal/unused)
│ └── custom.rs # Custom command execution with error handling
└── utils/ # Utilities
├── mod.rs # Module exports
└── terminal.rs # Terminal detection (minimal/unused)
- Working:
DisplayConfig.show_logo,DisplayConfig.color_values,DisplayConfig.show_colors_label,DisplayConfig.field_colors,InfoConfig.fields,InfoConfig.custom_commands,AsciiArtConfig - Structure: TOML-based with automatic file generation and custom config path support
- Location:
~/.config/rice/config.toml(Linux/macOS),%APPDATA%/rice/config.toml(Windows) - Custom Commands: HashMap of command name to shell command string
- Main Logic:
Display::render()andDisplay::render_with_ascii() - Layout: Horizontal ASCII art + info side-by-side, respects config field order
- Colors: Configurable color scheme using
coloredcrate with field_colors HashMap - Color Blocks: Dual-row colored blocks display (regular and bright variants)
- Custom Field Labels: Automatic capitalization and formatting of custom field names
- InfoCollector: Gathers system information based on config fields, supports custom commands
- Built-in Fields: os, hostname, userhost, kernel, uptime, packages, shell, resolution, de, wm, terminal, cpu, memory, disk, colors
- Custom Commands: Execute shell commands and display output as fields
- Module Organization:
system.rs: OS, hostname, userhost, kernel, uptimehardware.rs: CPU, memory, disksoftware.rs: Shell, terminal, packages, resolution, DE, WMcustom.rs: Command execution with output limiting and error handling
- Modern Mode: Default neofetch-style output (show command)
- Legacy Mode: Detailed system monitoring (system, cpu, memory, disk, network commands)
- Config Command: Generates config file and opens in editor
- Random Startup Messages:
get_random_startup_message()provides varied tracing log messages during development - Options:
--format: Output format (text, json)--no-logo: Disable ASCII art--image: Path to image file (experimental)--config: Custom config file path
- No Dead Code: Remove unused functions, avoid tech debt
- Working Features Only: Don't expose configuration options that don't work
- Clear Documentation: Mark features as working/planned/not implemented
- Cross-Platform: Test on macOS, Linux, Windows
- Honest Config: Only include options that actually work
- Clear Comments: Mark unimplemented features clearly
- Backward Compatibility: Maintain existing config structure when extending
- Add field logic to appropriate module in
src/info/(system.rs, hardware.rs, software.rs) - Add case to match statement in
src/info/mod.rs::collect_field() - Add field name to default config in
src/config/defaults.rs - Update field documentation in README.md
- Test on multiple platforms
- Custom commands are already fully implemented
- Users can add them via config file
[info.custom_commands]section - Commands are executed in order and integrated with built-in fields
- Failed commands are silently skipped
- Add option to appropriate config struct in
src/config/mod.rs - Implement logic in
src/display/mod.rs - Update default config TOML
- Update example config and README
- Test on multiple platforms using CI or local VMs
- Use
cfg!()macros for platform-specific code - Prefer cross-platform libraries when available
- ASCII art display (auto-detection, builtin selection)
- System information collection (15+ built-in fields including colors and userhost)
- Custom commands execution and display with configurable field order
- Configuration file system (generation, editing, custom config paths)
- Customizable field colors (16 color options) including custom command colors
- Colored blocks display (neofetch-style)
- Cross-platform paths and command execution
- CLI argument parsing with --config flag support
- JSON output format including custom command results
- Legacy command compatibility
- Show/hide colors label configuration
- Automatic field label formatting for custom commands
- Custom ASCII art from files (structure exists, CLI flag available)
- Alternative layouts (code exists but unused)
- Image display support (--image flag exists but experimental)
- Layout customization (vertical, compact)
- Text formatting options (padding, separators)
- Network information integration
- Config File:
~/.config/rice/config.toml(Unix),%APPDATA%/rice/config.toml(Windows) - Example Config:
config.example.toml(in repo root) - Default Generation:
src/config/defaults.rs::default_config_toml()
- Detection Logic:
src/display/ascii_art.rs - Built-in Art: Embedded in
ascii_art.rs - Custom Path: Not yet implemented
- Run
cargo checkfor compilation - Run
cargo runto test basic functionality - Run
cargo run -- configto test config generation - Test with different config options (show_logo = false, custom fields)
- Test custom commands functionality with a test config file
- Verify cross-platform paths work correctly
- Test both text and JSON output formats
- Path Handling: Use
std::path::PathBufand platform detection - Config Parsing: Ensure TOML is valid and all required fields exist
- ASCII Art: Handle missing/invalid art gracefully
- Editor Detection: Test editor opening on different platforms
- Custom Commands: Commands may fail silently, ensure graceful error handling
- Field Order: Display respects config field order, not hardcoded arrays
clap: CLI argument parsing (v4.5)sysinfo: Cross-platform system information (v0.37)anyhow: Error handlingserde: Configuration serializationtoml: TOML parsingcolored: Terminal colors (v3.0)tracing: Loggingdirs: Cross-platform directory paths
- Prefer well-maintained, cross-platform crates
- Minimize dependencies when possible
- Use standard library when sufficient
- Keep dependency versions up to date
- Don't Add Non-Working Config Options: Users get frustrated when config options don't work
- Test Configuration Changes: Always verify config file generation and parsing
- Platform-Specific Code: Remember Windows uses different paths and commands
- ASCII Art Handling: Be careful with Unicode and terminal width calculations
- Backward Compatibility: Don't break existing config files or CLI commands
- Error Handling: Provide helpful error messages for common failures
- Custom Command Security: Commands are executed as-is, document security implications
- Display Field Order: Use config field order, not hardcoded arrays in display logic
- Alternative Layouts: Implement vertical and compact layouts
- Custom ASCII Art: Support loading art from files
- Performance: Optimize system information collection
- Testing: Add comprehensive test suite
- Image Display: Complete image display functionality
This documentation should be updated when significant architectural changes are made to the codebase.