use std::io::Write as _;
use std::path::Path;
use crate::decompiler::{Decompiler, OutputFormat};
use crate::error::Result;
use super::super::args::Cli;
impl Cli {
pub(super) fn run_cfg(&self, path: &Path, fail_on_unknown_opcodes: bool) -> Result<()> {
let handling = Self::unknown_handling(fail_on_unknown_opcodes);
let decompiler = Decompiler::with_unknown_handling(handling);
let data = Self::read_nef_bytes(path)?;
let manifest = self.load_manifest(path)?;
let result =
decompiler.decompile_bytes_with_manifest(&data, manifest, OutputFormat::Pseudocode)?;
self.write_stdout(|out| out.write_all(result.cfg_to_dot().as_bytes()))?;
Self::write_warnings(&mut std::io::stderr(), &result.warnings)?;
Ok(())
}
}