mirror of
https://github.com/stefanoamorelli/crabrl.git
synced 2026-04-18 07:10:42 +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:
27
examples/parse.rs
Normal file
27
examples/parse.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
//! Basic parsing example
|
||||
|
||||
use crabrl::Parser;
|
||||
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);
|
||||
}
|
||||
|
||||
let parser = Parser::new();
|
||||
let doc = parser.parse_file(&args[1])?;
|
||||
|
||||
println!("Parsed {} successfully", args[1]);
|
||||
println!(" Facts: {}", doc.facts.len());
|
||||
println!(" Contexts: {}", doc.contexts.len());
|
||||
println!(" Units: {}", doc.units.len());
|
||||
|
||||
// Show first 5 facts
|
||||
for fact in doc.facts.iter().take(5) {
|
||||
println!(" - {}: {}", fact.name, fact.value);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user