use std::io;
use std::path::PathBuf;
use clap::Parser;
mod util;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Cli {
#[clap(required = true)]
nessus: Vec<PathBuf>,
#[clap(short, long, conflicts_with="json")]
csv: bool,
#[clap(short, long, conflicts_with="csv")]
json: bool,
#[clap(short, long)]
output: Option<String>,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
util::warn("Use with caution. You are responsible for your actions.".to_string());
let writer: Box<dyn io::Write> = match cli.output {
Some(path) => Box::new(
std::fs::File::create(path).expect("An error occured with the output file")
), None => Box::new(io::stdout()), };
if cli.json {
nessusx::as_json(cli.nessus, writer);
} else {
nessusx::as_csv(cli.nessus, writer);
}
Ok(())
}