rain_metadata/cli/
validate.rs

1use clap::Parser;
2use std::path::PathBuf;
3use crate::meta::KnownMeta;
4
5/// command for validating a meta
6#[derive(Parser)]
7pub struct Validate {
8    /// The known meta to validate against.
9    #[arg(short, long)]
10    meta: KnownMeta,
11    /// The input path to the json serialized metadata to validate against the
12    /// known schema.
13    #[arg(short, long)]
14    input_path: PathBuf,
15}
16
17pub fn validate(v: Validate) -> anyhow::Result<()> {
18    let data: Vec<u8> = std::fs::read(v.input_path)?;
19    // If we can normalize the input data then it is valid.
20    let _normalized = v.meta.normalize(&data)?;
21    Ok(())
22}