pub mod commands;
pub mod output;
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Parser)]
#[command(name = "icookforms")]
#[command(version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
Scan(commands::ScanArgs),
Analyze(commands::AnalyzeArgs),
Report(commands::ReportArgs),
Compliance(commands::ComplianceArgs),
Forensics(commands::ForensicsArgs),
Ml(commands::MlArgs),
Version,
}
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum OutputFormat {
Human,
Json,
Yaml,
Csv,
}
impl Default for OutputFormat {
fn default() -> Self {
Self::Human
}
}
impl OutputFormat {
#[must_use]
pub fn is_human_readable(&self) -> bool {
matches!(self, Self::Human)
}
#[must_use]
pub fn is_machine_readable(&self) -> bool {
!self.is_human_readable()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_output_format_default() {
let format = OutputFormat::default();
assert!(matches!(format, OutputFormat::Human));
}
#[test]
fn test_output_format_human_readable() {
assert!(OutputFormat::Human.is_human_readable());
assert!(!OutputFormat::Json.is_human_readable());
assert!(!OutputFormat::Yaml.is_human_readable());
}
#[test]
fn test_output_format_machine_readable() {
assert!(!OutputFormat::Human.is_machine_readable());
assert!(OutputFormat::Json.is_machine_readable());
assert!(OutputFormat::Yaml.is_machine_readable());
}
}