use std::path::PathBuf;
use clap::{Args, ValueEnum, ValueHint};
use strum::Display;
use crate::util::get_writer_for_file_or_stdout;
#[derive(Args, Debug, Clone)]
#[command(next_help_heading = "Output Options")]
pub struct OutputArgs<Format: ValueEnum + Send + Sync + 'static> {
#[arg(global = true, long, short, value_hint = ValueHint::FilePath)]
pub output: Option<PathBuf>,
#[arg(global = true, long, short, default_value = "pretty")]
pub format: Format,
}
impl<Format: ValueEnum + Send + Sync> OutputArgs<Format> {
pub fn get_writer(&self) -> std::io::Result<Box<dyn std::io::Write>> {
get_writer_for_file_or_stdout(self.output.as_ref())
}
pub fn has_output(&self) -> bool {
self.output.is_some()
}
}
#[derive(Copy, Clone, Debug, Display, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
#[strum(serialize_all = "kebab-case")]
pub enum ReportOutputFormat {
Pretty,
Json,
Jsonl,
Bson,
Toon,
Sarif,
Html,
}
#[derive(Copy, Clone, Debug, Display, PartialEq, Eq, PartialOrd, Ord, ValueEnum)]
#[strum(serialize_all = "kebab-case")]
pub enum GitHubOutputFormat {
Pretty,
Json,
Jsonl,
Bson,
Sarif,
}