preserves/implementations/rust/preserves-schema/src/bin/preserves-schema-rs.rs

30 lines
717 B
Rust

use std::io::Error;
use std::path::PathBuf;
use structopt::StructOpt;
use preserves_schema::compiler::{CompilerConfig, compile, expand_inputs};
#[derive(Clone, StructOpt, Debug)]
struct CommandLine {
#[structopt(short, long)]
output_dir: PathBuf,
#[structopt(long)]
prefix: String,
#[structopt(long)]
support_crate: Option<String>,
input_glob: Vec<String>,
}
fn main() -> Result<(), Error> {
let args = CommandLine::from_args();
let mut config = CompilerConfig::new(args.output_dir, args.prefix);
if let Some(c) = args.support_crate {
config.support_crate = c;
}
config.load_schemas_and_bundles(&expand_inputs(&args.input_glob)?)?;
compile(&config)
}