# Contributing to hawk ๐ฆ
Thank you for your interest in contributing to hawk! We welcome contributions from everyone, whether you're fixing a bug, adding a feature, improving documentation, or suggesting enhancements.
## ๐ค Ways to Contribute
- ๐ **Bug Reports**: Found an issue? Let us know!
- โจ **Feature Requests**: Have an idea for improvement?
- ๐ง **Code Contributions**: Bug fixes, new features, optimizations
- ๐ **Documentation**: Improve README, add examples, write tutorials
- ๐งช **Testing**: Add test cases, improve test coverage
- ๐ก **Examples**: Real-world use cases and sample datasets
## ๐ Getting Started
### Development Setup
1. **Fork the repository**
```bash
git clone https://github.com/kyotalab/hawk.git
cd hawk
```
2. **Install Rust** (if not already installed)
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
```
3. **Build the project**
```bash
cargo build
```
4. **Run tests**
```bash
cargo test
```
5. **Try it out**
```bash
cargo run -- '.users[0].name' sample-data/users.json
```
### Development Workflow
1. **Create a branch** for your changes
```bash
git checkout -b feature/amazing-feature
```
2. **Make your changes** with clear, focused commits
3. **Test thoroughly**
```bash
cargo test
cargo clippy cargo fmt ```
4. **Submit a Pull Request** with a clear description
## ๐ Reporting Bugs
When reporting bugs, please include:
### Bug Report Template
```
**Describe the bug**
A clear description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Run command '...'
2. With data file '...'
3. See error
**Expected behavior**
What you expected to happen.
**Actual behavior**
What actually happened.
**Environment**
- OS: [e.g., Ubuntu 22.04, macOS 13.0, Windows 11]
- Rust version: [e.g., 1.70.0]
- hawk version: [e.g., 0.1.0]
**Sample data (if applicable)**
Minimal example that reproduces the issue.
**Additional context**
Any other relevant information.
```
## โจ Feature Requests
We love new ideas! When suggesting features:
### Feature Request Template
```
**Feature Summary**
Brief description of the feature.
**Motivation**
Why would this feature be useful? What problem does it solve?
**Proposed Solution**
How should this feature work?
**Example Usage**
Show how users would interact with this feature:
**Alternatives Considered**
Are there other ways to solve this problem?
**Additional Context**
Any other relevant information, mockups, or examples.
```
## ๐ป Code Contributions
### Coding Standards
- **Follow Rust conventions**: Use `cargo fmt` and `cargo clippy`
- **Write tests**: All new features should include tests
- **Document public APIs**: Add doc comments for public functions
- **Keep it simple**: Prefer readable code over clever code
- **Follow existing patterns**: Match the existing codebase style
### Code Organization
```
src/
โโโ main.rs # Entry point
โโโ lib.rs # Library root
โโโ cli.rs # Command line interface
โโโ error.rs # Error types
โโโ setup.rs # File reading & format detection
โโโ parser.rs # Query parsing
โโโ executor.rs # Query execution
โโโ filter.rs # Filtering & aggregation
โโโ output.rs # Output formatting
โโโ utils.rs # Utility functions
```
### Adding New Features
1. **Start with tests**: Write tests for your feature first
2. **Implement incrementally**: Break large features into smaller chunks
3. **Update documentation**: Add examples and update README if needed
4. **Consider backwards compatibility**: Don't break existing queries
### Example: Adding a New Aggregation Function
```rust
// 1. Add to apply_pipeline_operation in filter.rs
} else if operation.starts_with("median(") && operation.ends_with(")") {
let field = &operation[7..operation.len()-1];
let field_name = field.trim_start_matches('.');
if is_grouped_data(&data) {
apply_aggregation_to_groups(data, "median", field_name)
} else {
calculate_median_simple(data, field_name)
}
// 2. Implement the calculation function
fn calculate_median_simple(data: Vec<Value>, field_name: &str) -> Result<Vec<Value>, Error> {
// Implementation here
}
// 3. Add group support in apply_aggregation_to_groups
"median" => calculate_median(items, field_name)?,
// 4. Write tests
#[test]
fn test_median_calculation() {
// Test cases here
}
```
## ๐งช Testing Guidelines
### Running Tests
```bash
cargo test # All tests
cargo test test_name # Specific test
cargo test --test integration # Integration tests only
```
### Test Categories
1. **Unit Tests**: Test individual functions
```rust
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_parse_simple_query() {
}
}
```
2. **Integration Tests**: Test complete workflows
```rust
#[test]
fn test_csv_groupby_workflow() {
}
```
3. **Example Tests**: Verify README examples work
```rust
#[test]
fn test_readme_examples() {
}
```
### Adding Test Data
Place test files in `tests/data/`:
```
tests/
โโโ data/
โ โโโ users.json
โ โโโ sales.csv
โ โโโ config.yaml
โโโ integration_test.rs
```
## ๐ Documentation Guidelines
### Code Documentation
```rust
/// Calculates the median value for a numeric field
///
/// # Arguments
/// * `data` - Vector of JSON values to process
/// * `field_name` - Name of the field to calculate median for
///
/// # Examples
/// ```
/// let result = calculate_median(data, "price")?;
/// ```
pub fn calculate_median(data: Vec<Value>, field_name: &str) -> Result<Value, Error> {
// Implementation
}
```
### README Updates
- Add new features to the feature list
- Include usage examples
- Update the comparison table if needed
- Add real-world use cases
## ๐ฏ Priority Areas
We're especially interested in contributions in these areas:
### High Priority
- ๐ **Bug fixes**: Any correctness issues
- ๐ **Performance improvements**: Memory usage, speed optimizations
- ๐ **New aggregation functions**: `median`, `stddev`, `percentile`
- ๐ง **CSV improvements**: Better type detection, delimiter handling
### Medium Priority
- ๐ **Output formats**: XML, TSV support
- ๐ **Query enhancements**: Regular expressions, string functions
- ๐ **Visualization**: ASCII charts, histograms
- ๐ **Streaming**: Large file support
### Lower Priority
- ๐จ **UI improvements**: Colors, better formatting
- ๐ฆ **Packaging**: Homebrew, APT packages
- ๐ **Plugins**: Extensibility system
## ๐ Pull Request Guidelines
### Before Submitting
- [ ] All tests pass (`cargo test`)
- [ ] Code is formatted (`cargo fmt`)
- [ ] No clippy warnings (`cargo clippy`)
- [ ] Documentation updated if needed
- [ ] Examples work as expected
### PR Description Template
```
## Summary
Brief description of changes
## Motivation
Why is this change needed?
## Changes
- [ ] Feature A added
- [ ] Bug B fixed
- [ ] Tests updated
## Testing
How was this tested?
## Breaking Changes
Any backwards incompatible changes?
## Related Issues
Fixes #123
```
## ๐ Recognition
Contributors will be recognized in:
- README acknowledgments
- Release notes
- GitHub contributors page
## ๐ Getting Help
- ๐ฌ **Discussions**: Use GitHub Discussions for questions
- ๐ **Issues**: Use GitHub Issues for bugs and feature requests
- ๐ง **Email**: Contact maintainers for sensitive issues
## ๐ Code of Conduct
We follow the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct). Please be respectful and inclusive in all interactions.
## ๐ Thank You!
Every contribution helps make hawk better for everyone. Whether it's a typo fix or a major feature, we appreciate your effort!
---
Happy contributing! ๐ฆ