1use std::path::PathBuf;
2
3use clap::{Parser, ValueEnum};
4
5use crate::graph::RiskTier;
6
7#[derive(Debug, Clone, Parser)]
8#[command(name = "blast-radius")]
9#[command(
10 version,
11 about = "Estimate the transitive blast radius of frontend code changes"
12)]
13pub struct Cli {
14 #[command(subcommand)]
15 pub command: Command,
16
17 #[arg(long, default_value = ".")]
18 pub repo_root: PathBuf,
19
20 #[arg(long, value_enum, default_value_t = OutputFormat::Tree)]
21 pub format: OutputFormat,
22
23 #[arg(long)]
24 pub output: Option<PathBuf>,
25
26 #[arg(long, short = 'v', global = true, default_value_t = false)]
28 pub verbose: bool,
29
30 #[arg(long)]
32 pub fail_threshold: Option<usize>,
33
34 #[arg(long, value_enum)]
36 pub fail_on_risk: Option<RiskTier>,
37}
38
39#[derive(Debug, Clone, Parser)]
40pub enum Command {
41 Export {
43 file: PathBuf,
44 export_name: String,
45 },
46 File {
47 file: PathBuf,
48 },
49 Files {
52 #[arg(required = true, num_args = 1..)]
53 files: Vec<PathBuf>,
54 },
55}
56
57#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
58pub enum OutputFormat {
59 Tree,
60 Json,
61 Mermaid,
62 Dot,
63}
64
65impl Cli {
66 pub fn parse_args() -> Self {
67 Self::parse()
68 }
69}