PI55U5GZKMYTPKYXC26MVSRK6IO5B63CX2PSAGWXNINZAUFROTNAC
use std::process::Command;
#[test]
fn exe_works() {
let output = Command::new(env!("CARGO_BIN_EXE_kdl-schema-check"))
.args(["tests/kdl-schema.kdl", "tests/kdl-schema.kdl"])
.output()
.unwrap();
assert_eq!(output.stdout, b"Validation succeeded!\n");
assert_eq!(output.stderr, b"");
assert!(output.status.success());
}
// TODO test more exhaustively
fn main() {
println!("Hello, world!");
use std::path::PathBuf;
use clap::Parser;
use kdl_schema::Schema;
use kdl_schema_check::CheckExt;
use miette::{IntoDiagnostic, Result};
/// Check if a KDL document matches a KDL schema
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
/// Don't print a confirmation if validation succeeds
#[clap(short, long)]
quiet: bool,
/// Path to schema KDL file
schema: PathBuf,
/// Path to document KDL file
document: PathBuf,
fn main() -> Result<()> {
let args = Args::parse();
// TODO use kdl_schema file parse API
let schema_data = std::fs::read_to_string(args.schema).into_diagnostic()?;
let schema = Schema::parse(&schema_data)?;
schema.check_file_matches(args.document)?;
if !args.quiet {
println!("Validation succeeded!");
}
Ok(())
}
[[package]]
name = "clap"
version = "3.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123"
dependencies = [
"atty",
"bitflags",
"clap_derive",
"indexmap",
"lazy_static",
"os_str_bytes",
"strsim",
"termcolor",
"textwrap 0.15.0",
]