Newer
Older
use opossum::{
OpticScenery,
{
console::{Args, PartialArgs},
use std::fs::{self, File};
use std::io::Write;
use std::path::Path;
fn read_and_parse_model(path: &Path) -> OpmResult<OpticScenery> {
OpossumError::Console(format!("cannot read file {} : {}", path.display(), e))
let scenery: OpticScenery = serde_json::from_str(&contents)
.map_err(|e| OpossumError::OpticScenery(format!("parsing of model failed: {}", e)))?;
let mut scenery = read_and_parse_model(&opossum_args.file_path)?;
let mut dot_path = opossum_args.report_directory.clone();
dot_path.push(opossum_args.file_path.file_stem().unwrap());
dot_path.set_extension("dot");
print!("Write diagram to {}...", dot_path.display());
let mut output = File::create(dot_path).unwrap();
print!("\nAnalyzing...");
scenery.analyze(&opossum_args.analyzer)?;
println!("Success\n");
let mut report_path = opossum_args.report_directory.clone();
report_path.push("report.json");
print!("Write detector report to {}...", report_path.display());
let mut output = File::create(report_path).unwrap();
write!(
output,
"{}",
serde_json::to_string_pretty(&scenery.report(&opossum_args.report_directory)).unwrap()
)
.unwrap();
println!("Success");