mirror of
https://github.com/stefanoamorelli/crabrl.git
synced 2026-04-18 23:30:45 +00:00
feat: implement CLI for XBRL parsing and validation
- Parse command with optional stats flag - Validate command with SEC EDGAR profile support - Benchmark command for performance testing - Colored output for better UX
This commit is contained in:
35
examples/validate.rs
Normal file
35
examples/validate.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
//! Validation example
|
||||
|
||||
use crabrl::{Parser, Validator};
|
||||
use std::env;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() != 2 {
|
||||
eprintln!("Usage: {} <xbrl-file>", args[0]);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// Parse
|
||||
let parser = Parser::new();
|
||||
let doc = parser.parse_file(&args[1])?;
|
||||
|
||||
// Validate
|
||||
let validator = Validator::new();
|
||||
let result = validator.validate(&doc)?;
|
||||
|
||||
if result.is_valid {
|
||||
println!("✓ Document is valid");
|
||||
} else {
|
||||
println!("✗ Document has {} errors", result.errors.len());
|
||||
for error in result.errors.iter().take(5) {
|
||||
println!(" - {}", error);
|
||||
}
|
||||
}
|
||||
|
||||
println!("\nValidation stats:");
|
||||
println!(" Facts validated: {}", result.stats.facts_validated);
|
||||
println!(" Time: {}ms", result.stats.duration_ms);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user