ferrous_forge/commands/mod.rs
1//! Command implementations for Ferrous Forge
2
3use clap::Subcommand;
4
5/// Available commands for Ferrous Forge
6#[derive(Subcommand)]
7pub enum Commands {
8 /// Initialize Ferrous Forge system-wide
9 Init {
10 /// Force initialization even if already configured
11 #[arg(short, long)]
12 force: bool,
13 },
14 /// Show status of Ferrous Forge installation and configuration
15 Status,
16 /// Update Ferrous Forge to the latest version
17 Update {
18 /// Update channel to use (stable, beta, nightly)
19 #[arg(long, default_value = "stable")]
20 channel: String,
21 /// Only update rules, not the binary
22 #[arg(short, long)]
23 rules_only: bool,
24 /// Show what would be updated without actually updating
25 #[arg(short, long)]
26 dry_run: bool,
27 },
28 /// Manage configuration settings
29 Config {
30 /// Set a configuration value (key=value)
31 #[arg(short, long)]
32 set: Option<String>,
33 /// Get a configuration value
34 #[arg(short, long)]
35 get: Option<String>,
36 /// List all configuration values
37 #[arg(short, long)]
38 list: bool,
39 /// Reset configuration to defaults
40 #[arg(short, long)]
41 reset: bool,
42 },
43 /// Validate a Rust project against standards
44 Validate {
45 /// Path to the project to validate (defaults to current directory)
46 path: Option<std::path::PathBuf>,
47 /// Generate AI-friendly compliance report
48 #[arg(long)]
49 ai_report: bool,
50 /// Compare with previous report
51 #[arg(long)]
52 compare_previous: bool,
53 },
54 /// Rollback to a previous version
55 Rollback {
56 /// Version to rollback to
57 version: String,
58 },
59 /// Uninstall Ferrous Forge from the system
60 Uninstall {
61 /// Confirm uninstallation without prompting
62 #[arg(short, long)]
63 confirm: bool,
64 },
65 /// Rust version management
66 Rust {
67 /// Rust version management subcommand
68 #[command(subcommand)]
69 command: RustCommand,
70 },
71 /// Edition management
72 Edition {
73 /// Edition management subcommand
74 #[command(subcommand)]
75 command: EditionCommand,
76 },
77 /// Safety pipeline management
78 Safety {
79 /// Safety pipeline subcommand
80 #[command(subcommand)]
81 command: SafetyCommand,
82 },
83 /// Project template management
84 Template {
85 /// Template subcommand
86 #[command(subcommand)]
87 command: template::TemplateCommand,
88 },
89 /// Automatically fix code violations
90 Fix {
91 /// Path to the project to fix (defaults to current directory)
92 path: Option<std::path::PathBuf>,
93 /// Only fix specific violation types (comma-separated)
94 #[arg(long)]
95 only: Option<String>,
96 /// Skip specific violation types (comma-separated)
97 #[arg(long)]
98 skip: Option<String>,
99 /// Show what would be fixed without making changes
100 #[arg(long)]
101 dry_run: bool,
102 /// Fix at most this many violations (for testing)
103 #[arg(long)]
104 limit: Option<usize>,
105 /// Enable AI-powered analysis for complex violations
106 #[arg(long)]
107 ai_analysis: bool,
108 },
109}
110
111/// Rust version management subcommands
112#[derive(Subcommand)]
113pub enum RustCommand {
114 /// Check current Rust version and available updates
115 Check {
116 /// Show verbose output
117 #[arg(short, long)]
118 verbose: bool,
119 },
120 /// Get update recommendations
121 Recommend {
122 /// Only consider stable releases
123 #[arg(short, long)]
124 stable_only: bool,
125 },
126 /// List recent Rust releases
127 List {
128 /// Number of releases to show
129 #[arg(short, long, default_value = "10")]
130 count: usize,
131 },
132}
133
134/// Edition management subcommands
135#[derive(Subcommand)]
136pub enum EditionCommand {
137 /// Check edition compliance
138 Check {
139 /// Project path
140 #[arg(default_value = ".")]
141 path: std::path::PathBuf,
142 },
143 /// Migrate to a new edition
144 Migrate {
145 /// Target edition (2018, 2021, 2024)
146 #[arg(default_value = "2024")]
147 edition: String,
148 /// Skip backup creation
149 #[arg(long)]
150 no_backup: bool,
151 /// Run tests after migration
152 #[arg(long)]
153 test: bool,
154 /// Apply edition idioms
155 #[arg(long)]
156 idioms: bool,
157 },
158 /// Analyze edition compatibility
159 Analyze {
160 /// Project path
161 #[arg(default_value = ".")]
162 path: std::path::PathBuf,
163 /// Target edition
164 #[arg(default_value = "2024")]
165 edition: String,
166 },
167}
168
169/// Safety pipeline management subcommands
170#[derive(Subcommand)]
171pub enum SafetyCommand {
172 /// Check safety pipeline status
173 Status,
174 /// Install git hooks for safety pipeline
175 Install {
176 /// Force reinstall even if hooks already exist
177 #[arg(short, long)]
178 force: bool,
179 /// Project path
180 #[arg(default_value = ".")]
181 path: std::path::PathBuf,
182 },
183 /// Run safety checks manually
184 Check {
185 /// Pipeline stage to check
186 #[arg(long, default_value = "pre-commit")]
187 stage: String,
188 /// Project path
189 #[arg(default_value = ".")]
190 path: std::path::PathBuf,
191 /// Show verbose output
192 #[arg(short, long)]
193 verbose: bool,
194 },
195 /// Test individual safety checks
196 Test {
197 /// Project path
198 #[arg(default_value = ".")]
199 path: std::path::PathBuf,
200 },
201}
202
203pub mod config;
204pub mod edition;
205pub mod fix;
206pub mod init;
207pub mod rollback;
208pub mod rust;
209pub mod safety;
210pub mod status;
211pub mod template;
212pub mod uninstall;
213pub mod update;
214pub mod validate;