use anyhow::Result;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
mod analysis;
mod commands;
mod parser;
pub use analysis::*;
pub use parser::*;
#[derive(Parser)]
#[command(name = "slimwasm")]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Top {
path: PathBuf,
#[arg(short = 'n', long, default_value = "20")]
limit: usize,
#[arg(short, long)]
retained: bool,
#[arg(long)]
json: bool,
},
Why {
path: PathBuf,
name: String,
#[arg(short, long, default_value = "10")]
depth: usize,
#[arg(long)]
json: bool,
},
Diff {
old: PathBuf,
new: PathBuf,
#[arg(short = 'n', long, default_value = "20")]
limit: usize,
#[arg(long)]
json: bool,
},
Exports {
path: PathBuf,
#[arg(long)]
json: bool,
},
}
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::Top {
path,
limit,
retained,
json,
} => commands::top::run(&path, limit, retained, json),
Commands::Why {
path,
name,
depth,
json,
} => commands::why::run(&path, &name, depth, json),
Commands::Diff {
old,
new,
limit,
json,
} => commands::diff::run(&old, &new, limit, json),
Commands::Exports { path, json } => commands::exports::run(&path, json),
}
}