The project uses [cargo-xtask](https://github.com/matklad/cargo-xtask) for automation of tests and builds. This approach allows us to write build scripts and automation tasks in Rust instead of shell scripts, making them more maintainable and cross-platform.
### Available Commands
The following commands are available through cargo-xtask:
```bash
cargo xtask setup-test-env # Set up the test environment for repository tests
cargo xtask build # Build the project
cargo xtask build -r # Build with release optimizations
cargo xtask build -p <crate> # Build a specific crate
cargo xtask test # Run tests
cargo xtask test -r # Run tests with release optimizations
cargo xtask test -p <crate> # Run tests for a specific crate
cargo xtask fmt # Format code using cargo fmt
cargo xtask clippy # Run clippy for code quality checks
cargo xtask clean # Clean build artifacts
```
### Adding New Commands
To add a new command to cargo-xtask:
1. Edit the `xtask/src/main.rs` file
2. Add a new variant to the `Commands` enum
3. Implement a function for the new command
4. Add a match arm in the `main` function to call your new function
- Use `cargo clippy` to check for common mistakes and improve code quality
### Naming Conventions
- Use snake_case for variables, functions, and modules
- Use CamelCase for types, traits, and enums
- Use SCREAMING_SNAKE_CASE for constants
- Prefix unsafe functions with `unsafe_`
### Documentation
- Document all public items with doc comments
- Include examples in doc comments where appropriate
- Document error conditions and return values
### Error Handling
- Follow the error handling guidelines above
- Use the ? operator for error propagation where appropriate
- Avoid using `unwrap()` or `expect()` in production code
### Logging
- Use the tracing crate for logging
- Use appropriate log levels:
-`trace`: Very detailed information
-`debug`: Useful information for debugging
-`info`: General information about the application's operation
-`warn`: Potentially problematic situations
-`error`: Error conditions
## Workflow for Junie
When working on the IPS project, Junie should follow this workflow:
1.**Understand the Issue**: Thoroughly review the issue description and related code
2.**Plan the Changes**: Create a plan for implementing the changes
3.**Implement the Changes**: Make the necessary changes to the code
4.**Test the Changes**: Run tests to ensure the changes work as expected
5.**Document the Changes**: Update documentation as needed
6.**Submit the Changes**: Submit the changes for review
When implementing error handling, Junie should follow the error handling guidelines above and use the decision tree to determine the appropriate approach.