use std::path::PathBuf;
use clap::{Parser, Subcommand};
pub mod config;
mod commands {
pub mod analyze;
pub mod diff;
pub mod fix;
pub mod list;
pub mod report;
pub mod watch;
}
mod output {
pub mod terminal;
}
#[derive(Parser)]
#[command(name = "padlock", about = "Struct memory layout analyzer")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Analyze {
path: PathBuf,
#[arg(long)]
json: bool,
#[arg(long)]
sarif: bool,
},
List { path: PathBuf },
Diff { path: PathBuf },
Fix {
path: PathBuf,
#[arg(long)]
dry_run: bool,
},
Report {
path: PathBuf,
#[arg(long)]
json: bool,
},
Watch {
path: PathBuf,
#[arg(long)]
json: bool,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Analyze { path, json, sarif } => commands::analyze::run(&path, json, sarif),
Commands::List { path } => commands::list::run(&path),
Commands::Diff { path } => commands::diff::run(&path),
Commands::Fix { path, dry_run } => commands::fix::run(&path, dry_run),
Commands::Report { path, json } => commands::analyze::run(&path, json, false),
Commands::Watch { path, json } => commands::watch::run(&path, json),
}
}