verify_compactified/
verify_compactified.rs

1//! Verify that a compactified appinfo.vdf file parses correctly.
2
3use std::env;
4use steam_vdf_parser::binary::parse_appinfo;
5
6fn main() {
7    let args: Vec<String> = env::args().collect();
8
9    if args.len() < 2 {
10        eprintln!("Usage: {} <vdf_file>", args[0]);
11        std::process::exit(1);
12    }
13
14    let path = &args[1];
15
16    // Read the file
17    let data = match std::fs::read(path) {
18        Ok(d) => d,
19        Err(e) => {
20            eprintln!("Error reading file: {}", e);
21            std::process::exit(1);
22        }
23    };
24
25    // Parse it
26    match parse_appinfo(&data) {
27        Ok(vdf) => {
28            println!("Successfully parsed {}", path);
29            println!("Root key: {}", vdf.key());
30            if let Some(obj) = vdf.as_obj() {
31                println!("Number of apps: {}", obj.len());
32                for (key, _) in obj.iter().take(5) {
33                    println!("  - app_id: {}", key);
34                }
35                if obj.len() > 5 {
36                    println!("  ... and {} more", obj.len() - 5);
37                }
38            }
39        }
40        Err(e) => {
41            eprintln!("Error parsing file: {:?}", e);
42            std::process::exit(1);
43        }
44    }
45}