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

30 lines
717 B
Rust
Raw Normal View History

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