mirror of
https://github.com/stefanoamorelli/crabrl.git
synced 2026-04-18 07:10:42 +00:00
- Apply consistent formatting to examples - Fix Error enum formatting in lib.rs - Format if-else expressions properly
28 lines
750 B
Rust
28 lines
750 B
Rust
//! Parse and display XBRL file info
|
|
|
|
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 {}:", args[1]);
|
|
println!(" Facts: {}", doc.facts.len());
|
|
println!(" Contexts: {}", doc.contexts.len());
|
|
println!(" Units: {}", doc.units.len());
|
|
|
|
// Show first 5 facts
|
|
let facts_vec: Vec<_> = doc.facts.clone().into();
|
|
for fact in facts_vec.iter().take(5) {
|
|
println!(" - {}: {}", fact.name, fact.value);
|
|
}
|
|
|
|
Ok(())
|
|
} |