Thank you for your interest in contributing to gim! This document outlines the process and guidelines for contributing to the project.
gim is a fast, high-performance, modular system metrics and diagnostics CLI tool written in Rust. It collects and displays system metrics like CPU, memory, disk, and network usage.
- Fork the repository
- Clone your fork:
git clone https://github.com/your-username/gim.git - Create a new branch:
git checkout -b feature/your-feature-name - Make your changes
- Test thoroughly
- Submit a pull request
# Install Rust if you don't have it
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build the project
cargo build
# Run the project
cargo run
# Run tests
cargo test
# Format code
cargo fmt
# Check for linting issues
cargo clippysrc/
├── lib.rs # Main application logic
├── main.rs # Entry point
├── cli/ # Command line interface parsing
├── core/ # Core data structures and traits
├── modules/ # Metric collection modules
├── output/ # Output formatting logic
└── tui/ # Terminal UI (planned future feature)
To add a new metric collection module:
- Create a new file in
src/modules/(e.g.,disk.rs) - Implement the
MetricCollectortrait - Add the module to
src/modules/mod.rs - Register the module in the main function in
src/lib.rs - Update the CLI to accept your module as an argument (if needed)
Example module implementation:
use crate::core::{MetricCollector, MetricData, MetricValue};
use std::collections::HashMap;
pub struct NewCollector {}
impl NewCollector {
pub fn new() -> Self {
NewCollector {}
}
}
impl MetricCollector for NewCollector {
fn collect(&self) -> Result<MetricData, Box<dyn std::error::Error>> {
let mut metrics = HashMap::new();
// Collect your metrics here
metrics.insert("metric_name".to_string(), MetricValue::from(42));
Ok(MetricData {
timestamp: std::time::SystemTime::now(),
metrics,
})
}
fn name(&self) -> &'static str {
"module_name"
}
}- Follow Rust idioms and best practices
- Use
cargo fmtto format code - Add documentation comments for public APIs
- Write tests for new functionality
- Keep functions focused and well-named
- Describe your changes clearly in the PR description
- Include tests if adding new functionality
- Ensure all tests pass before submitting
- Link any relevant issues
- Keep PRs focused on a single feature or fix
If you have questions, feel free to open an issue or reach out to the maintainers.