1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use clap::{Parser, Subcommand, ValueEnum};
use repopilot::output::OutputFormat;
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "repopilot")]
#[command(about = "Local-first codebase audit CLI", long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Compare two JSON scan reports and show what changed
Compare {
/// Path to the earlier scan report (JSON)
before: std::path::PathBuf,
/// Path to the more recent scan report (JSON)
after: std::path::PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "console")]
format: CompareOutputFormatArg,
/// Write report to a file instead of stdout
#[arg(short, long)]
output: Option<std::path::PathBuf>,
},
/// Scan a project, folder, or file
Scan {
/// Path to project, folder, or file
path: PathBuf,
/// Output format
#[arg(long, value_enum)]
format: Option<OutputFormatArg>,
/// Write report to a file instead of stdout
#[arg(short, long)]
output: Option<PathBuf>,
/// Path to a RepoPilot config file
#[arg(long)]
config: Option<PathBuf>,
/// Maximum non-empty LOC before a file is reported as large (default: 300)
#[arg(long)]
max_file_loc: Option<usize>,
/// Maximum number of files in a single directory before flagging (default: 20)
#[arg(long)]
max_directory_modules: Option<usize>,
/// Maximum directory nesting depth before flagging (default: 5)
#[arg(long)]
max_directory_depth: Option<usize>,
},
/// Generate a default repopilot.toml configuration file
Init {
/// Overwrite an existing config file
#[arg(long)]
force: bool,
/// Path where the config file should be written
#[arg(long, default_value = "repopilot.toml")]
path: PathBuf,
},
}
#[derive(Clone, Copy, Debug, ValueEnum)]
pub enum OutputFormatArg {
Console,
Html,
Json,
Markdown,
}
#[derive(Clone, Copy, Debug, ValueEnum)]
pub enum CompareOutputFormatArg {
Console,
Json,
Markdown,
}
impl From<OutputFormatArg> for OutputFormat {
fn from(format: OutputFormatArg) -> Self {
match format {
OutputFormatArg::Console => OutputFormat::Console,
OutputFormatArg::Html => OutputFormat::Html,
OutputFormatArg::Json => OutputFormat::Json,
OutputFormatArg::Markdown => OutputFormat::Markdown,
}
}
}