Repository navigation
Expand file tree
/
Copy pathargs.rs
More file actions
168 lines (137 loc) · 4.76 KB
/
Copy pathargs.rs
File metadata and controls
168 lines (137 loc) · 4.76 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use std::path::PathBuf;
use clap::{Parser, Subcommand, ValueEnum};
/// QualiRS — structural and architectural code smell detector for Rust.
#[derive(Parser, Debug)]
#[command(name = "qualirs", version, about)]
pub struct Args {
#[command(subcommand)]
pub(crate) command: Option<Command>,
#[command(flatten)]
pub(crate) source: SourceOptions,
#[command(flatten)]
pub(crate) filters: FilterOptions,
#[command(flatten)]
pub(crate) output_options: OutputOptions,
/// List available detectors and exit
#[arg(long)]
pub(crate) list_detectors: bool,
}
#[derive(clap::Args, Debug)]
pub(crate) struct SourceOptions {
/// Path to the Rust project or file to analyze (defaults to current directory)
#[arg(conflicts_with_all = ["git", "crate_name"])]
pub(crate) path: Option<PathBuf>,
/// Git repository URL to clone and analyze
#[arg(long, value_name = "URL", conflicts_with = "crate_name")]
pub(crate) git: Option<String>,
/// Git branch to check out when using --git
#[arg(
long,
value_name = "BRANCH",
requires = "git",
conflicts_with_all = ["tag", "crate_name"]
)]
pub(crate) branch: Option<String>,
/// Git tag to check out when using --git
#[arg(
long,
value_name = "TAG",
requires = "git",
conflicts_with_all = ["branch", "crate_name"]
)]
pub(crate) tag: Option<String>,
/// crates.io crate name to download and analyze
#[arg(long = "crate", value_name = "CRATE", conflicts_with = "git")]
pub(crate) crate_name: Option<String>,
/// crates.io crate version to download when using --crate
#[arg(
long,
value_name = "VERSION",
requires = "crate_name",
conflicts_with = "git"
)]
pub(crate) crate_version: Option<String>,
/// Directory to create temporary git and crate analysis folders in
#[arg(long, value_name = "DIR")]
pub(crate) temp_dir: Option<PathBuf>,
/// Preserve temporary git and crate analysis folders after the run
#[arg(long)]
pub(crate) keep_temp: bool,
}
#[derive(clap::Args, Debug)]
pub(crate) struct FilterOptions {
/// Configuration file path (default: qualirs.toml in project root)
#[arg(short, long)]
pub(crate) config: Option<PathBuf>,
/// Number of analysis threads to use (0 = all logical CPUs)
#[arg(long)]
pub(crate) threads: Option<usize>,
/// Minimum severity to report: info, warning, critical
#[arg(short = 'm', long)]
pub(crate) min_severity: Option<String>,
/// Precision mode: conservative, balanced, exploratory
#[arg(long)]
pub(crate) precision: Option<String>,
/// Show only smells of a specific category
#[arg(short = 't', long)]
pub(crate) category: Option<String>,
}
#[derive(clap::Args, Debug)]
pub(crate) struct OutputOptions {
/// Show analysis elapsed time, CPU time, and peak process memory at the end
#[arg(long, conflicts_with = "list_detectors")]
pub(crate) stats: bool,
/// Quiet mode: only show summary counts
#[arg(short, long)]
pub(crate) quiet: bool,
/// Compact mode: show findings as a categorized list (default)
#[arg(long, conflicts_with_all = ["quiet", "table"])]
pub(crate) compact: bool,
/// Table mode: show findings in the legacy table layout
#[arg(long, conflicts_with_all = ["quiet", "compact", "llm"])]
pub(crate) table: bool,
/// LLM mode: show compact Markdown with fenced finding blocks for coding assistants
#[arg(long, conflicts_with_all = ["quiet", "compact", "how_fix"])]
pub(crate) llm: bool,
/// How-fix mode: explain each finding with the current source code and improvement guidance
#[arg(
long,
conflicts_with_all = ["quiet", "compact", "table", "llm", "format", "list_detectors"]
)]
pub(crate) how_fix: bool,
/// Output format
#[arg(
long,
value_enum,
conflicts_with_all = ["quiet", "compact", "table", "llm", "how_fix", "list_detectors"]
)]
pub(crate) format: Option<OutputFormat>,
/// Write JSON findings to a file instead of stdout
#[arg(
long = "output",
requires = "format",
conflicts_with = "list_detectors"
)]
pub(crate) output_path: Option<PathBuf>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, ValueEnum)]
pub(crate) enum OutputFormat {
Json,
}
#[derive(Subcommand, Debug)]
pub(crate) enum Command {
/// Generate a default qualirs.toml configuration file
InitConfig {
/// Config file to create
#[arg(short, long, default_value = "qualirs.toml")]
output: PathBuf,
/// Overwrite an existing config file
#[arg(short, long)]
force: bool,
},
}
impl Args {
pub fn parse_args() -> Self {
Parser::parse()
}
}