Development & Contribution
🏗️ Development & Contribution
We welcome and appreciate all forms of contribution, from bug reports and feature suggestions to code submissions!
Project Structure
The application is structured into a few key Rust modules:
| File/Module | Description |
|---|---|
src/main.rs |
TUI Logic. Contains the App state, all TUI rendering (ui, render_list, render_detail, etc.), and the event handling loop (handle_events). This is where you’ll find the Ratatui code. |
src/cache.rs |
Data Layer. Manages the remote data fetching (download_fresh_data) and local caching (load_from_cache, is_cache_stale). Uses reqwest and dirs. |
src/types.rs |
Data Types. Defines the CratePackage, Metadata, and CratesData structs that mirror the remote JSON data structure. Uses serde. |
Cargo.toml |
Project manifest. Key dependencies are ratatui (for the TUI framework), crossterm (for terminal backend), and reqwest (for networking). |
Build & Test
To get your development environment ready:
- Clone the repository:
bash git clone [https://github.com/rvbug/ratcrates.git](https://github.com/rvbug/ratcrates.git) cd ratcrates - Run in development mode:
bash cargo run - Run unit tests (mainly for caching):
bash cargo test
Contributing Code
If you have a bug fix or feature you’d like to implement:
- Fork the repository on GitHub.
- Create a new branch for your work:
bash git checkout -b feature/my-new-feature - Implement your changes.
- Test your changes thoroughly.
- Commit your changes using a descriptive commit message (e.g., following the Conventional Commits specification).
bash git commit -m 'feat: add jump to last search result command' - Push your branch and open a Pull Request against the
mainbranch of the original repository.
Adding New Commands
To add a new command (e.g., :mycmd), you would modify src/main.rs: Extend execute_command: Add a new match arm in the execute_command function within the App implementation.
// In App::execute_command
match command {
// ... existing commands
"mycmd" => {
// Your new command logic goes here
self.status_message = "Executed mycmd!".to_string();
}
// ...
}- **Update `render_help`:** Add the new command to the list in the `render_help` function to ensure it appears in the in-app help view.