raz-core
Core library for RAZ (Rust Action Zapper) - Universal command generator for Rust projects.
Features
- Universal File Detection: Analyze any Rust file to determine execution context
- Stateless Operation: Works from any directory without workspace context
- Tree-sitter Powered: AST-driven test and function detection
- Smart Test Detection: Cursor-aware test discovery with module hierarchy
- Framework Providers: Specialized support for multiple frameworks
- Override Integration: Automatic loading of saved command configurations
- Validation Support: Smart command-line option validation
Quick Start
use ;
use Path;
async
Advanced Usage
File Detection
use ;
let context = detect_context?;
match context.file_type
Framework Providers
use ;
let mut registry = new;
registry.register;
registry.register;
let commands = registry.generate_commands?;
Complete Integration Example
This example shows how raz-core integrates with other RAZ crates:
use ;
use ;
use ;
use ;
use Path;
async
Crate Dependencies
- raz-common: Common utilities and error handling
- raz-config: Configuration management
- raz-validation: Command-line option validation
- raz-override: Override persistence and management
API Reference
Core Types
RazCore: Main entry point for command generationPosition: Cursor position (line, column) - 0-based indexingFileExecutionContext: Analysis result of a Rust fileExecutableCommand: Generated command with environment, args, and metadata
Key Methods
generate_universal_commands(): Main command generation with automatic override loadingFileDetector::detect_context(): Analyze file type and structureSmartOverrideParser::parse(): Parse override stringsOverrideSystem::resolve_override(): Load saved overrides
Supported Execution Patterns
RAZ can detect and execute any Rust file pattern:
| Pattern | Example | Command Generated |
|---|---|---|
| Main Binary | src/main.rs |
cargo run --bin project |
| Library | src/lib.rs |
cargo test --lib |
| Integration Test | tests/common.rs |
cargo test --test common |
| Unit Test | src/lib.rs:25:1 |
cargo test -- tests::my_test --exact |
| Example | examples/demo.rs |
cargo run --example demo |
| Benchmark | benches/perf.rs |
cargo bench --bench perf |
| Build Script | build.rs |
Direct execution |
| Cargo Script | script.rs |
cargo +nightly -Zscript script.rs |
| Standalone | /tmp/hello.rs |
rustc hello.rs && ./hello |
| Standalone Test | /tmp/test.rs:10:1 |
rustc --test test.rs && ./test my_test |
Test Macro Support
RAZ recognizes all common test macros:
#[test]- Standard test#[tokio::test]- Async runtime tests#[async_std::test]- Alternative async tests#[test_case(...)]- Parameterized tests#[bench]- Benchmarks
Universal Detection
RAZ works with:
- Cargo Workspaces: Multi-package projects with proper member detection
- Cargo Packages: Single package projects with bin/lib/test detection
- Cargo Scripts: Files with
#!/usr/bin/env -S cargo +nightly -Zscript - Single Files: Standalone Rust files compiled with rustc
- Any Directory: No need to be in project root - works from anywhere