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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
use crate::models::{ShellDialect, VerificationLevel};
use crate::validation::ValidationLevel;
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
// Re-export types from split modules so `crate::cli::args::Foo` continues to work
pub use super::args_corpus::*;
pub use super::args_tools::*;
#[derive(Parser)]
#[command(name = "bashrs")]
#[command(about = "Rust-to-Shell transpiler for deterministic bootstrap scripts")]
#[command(version = env!("CARGO_PKG_VERSION"))]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
/// Verification stringency level
#[arg(long, default_value = "strict")]
pub verify: VerificationLevel,
/// Target shell dialect
#[arg(long, default_value = "posix")]
pub target: ShellDialect,
/// ShellCheck-compatible validation level
#[arg(long, default_value = "minimal")]
pub validation: ValidationLevel,
/// Enable strict mode (fail on warnings)
#[arg(long)]
pub strict: bool,
/// Enable verbose output
#[arg(short, long)]
pub verbose: bool,
}
#[derive(Subcommand)]
pub enum Commands {
/// Transpile Rust source to shell script
Build {
/// Input Rust file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output shell script file
#[arg(short, long, default_value = "install.sh")]
output: PathBuf,
/// Emit verification proof
#[arg(long)]
emit_proof: bool,
/// Disable optimizations
#[arg(long)]
no_optimize: bool,
},
/// Check Rust source for Rash compatibility
Check {
/// Input Rust file
#[arg(value_name = "FILE")]
input: PathBuf,
},
/// Initialize new Rash project
Init {
/// Project directory (required — prevents accidental CWD mutation)
path: PathBuf,
/// Project name
#[arg(long)]
name: Option<String>,
},
/// Verify shell script matches Rust source
Verify {
/// Rust source file
rust_source: PathBuf,
/// Shell script file
shell_script: PathBuf,
},
/// Generate formal verification inspection report
Inspect {
/// Input AST file (JSON) or inline AST specification
#[arg(value_name = "AST")]
input: String,
/// Output format
#[arg(long, default_value = "markdown")]
format: InspectionFormat,
/// Output file (defaults to stdout)
#[arg(short, long)]
output: Option<PathBuf>,
/// Include detailed traces
#[arg(long)]
detailed: bool,
},
// Playground feature removed in v1.0 - will be moved to separate rash-playground crate in v1.1
/// Compile to standalone binary
Compile {
/// Input Rust source file
rust_source: PathBuf,
/// Output binary path
#[arg(short, long)]
output: PathBuf,
/// Runtime type
#[arg(long, value_enum, default_value = "dash")]
runtime: CompileRuntime,
/// Create self-extracting script instead of binary
#[arg(long)]
self_extracting: bool,
/// Build distroless container
#[arg(long)]
container: bool,
/// Container format
#[arg(long, value_enum, default_value = "oci")]
container_format: ContainerFormatArg,
},
/// Lint shell scripts or Rust source for safety issues
Lint {
/// Input file(s) or directories (shell script, Makefile, or Dockerfile)
#[arg(value_name = "FILE", required = true, num_args = 1..)]
input: Vec<PathBuf>,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: LintFormat,
/// Enable auto-fix suggestions (SAFE fixes only)
#[arg(long)]
fix: bool,
/// Apply fixes with assumptions (requires --fix, includes SAFE + SAFE-WITH-ASSUMPTIONS fixes)
#[arg(long, requires = "fix")]
fix_assumptions: bool,
/// Output file for fixed content
#[arg(short, long)]
output: Option<PathBuf>,
/// Disable .bashrsignore file processing (Issue #58)
#[arg(long)]
no_ignore: bool,
/// Path to ignore file (defaults to .bashrsignore in project root)
#[arg(long, value_name = "FILE")]
ignore_file: Option<PathBuf>,
/// Suppress info-level messages, show only warnings and errors (Issue #75)
#[arg(short = 'q', long)]
quiet: bool,
/// Minimum severity level to display (info, warning, error)
#[arg(long, value_enum, default_value = "info")]
level: LintLevel,
/// Ignore specific rule codes (comma-separated: SEC010,DET002)
#[arg(long, value_name = "RULES")]
ignore: Option<String>,
/// Exclude specific rule (shellcheck-compatible, can be repeated)
#[arg(short = 'e', value_name = "CODE", action = clap::ArgAction::Append)]
exclude: Option<Vec<String>>,
/// Export diagnostics in CITL format for OIP integration (Issue #83)
#[arg(long, value_name = "FILE")]
citl_export: Option<PathBuf>,
/// Lint profile for specialized validation (standard, coursera, devcontainer)
#[arg(long, value_enum, default_value = "standard")]
profile: LintProfileArg,
/// Enable graded output mode (educational scoring with pass/fail criteria)
#[arg(long)]
graded: bool,
/// CI mode: suppress colors, emit GitHub Actions annotations
#[arg(long)]
ci: bool,
/// Minimum severity to trigger non-zero exit code (default: warning)
#[arg(long, value_enum, default_value = "warning")]
fail_on: LintLevel,
},
/// Purify bash scripts (determinism + idempotency + safety)
Purify {
/// Input bash script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output file (defaults to stdout)
#[arg(short, long)]
output: Option<PathBuf>,
/// Show detailed transformation report
#[arg(long)]
report: bool,
/// Generate test suite for purified script
#[arg(long)]
with_tests: bool,
/// Generate property-based tests (100+ cases)
#[arg(long)]
property_tests: bool,
/// Enable gradual type checking (check type annotations in comments)
#[arg(long)]
type_check: bool,
/// Emit runtime type guards in purified output (implies --type-check)
#[arg(long)]
emit_guards: bool,
/// Treat type warnings as errors
#[arg(long)]
type_strict: bool,
/// Show unified diff of original vs purified output
#[arg(long)]
diff: bool,
/// Verify purified output passes shellcheck
#[arg(long)]
verify: bool,
/// Recursively purify all .sh files in a directory
#[arg(long)]
recursive: bool,
},
/// Combined safety check: lint findings + classification (SSC v11 S8.2)
SafetyCheck {
/// Input script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output as JSON
#[arg(long)]
json: bool,
/// Force format (auto-detected from extension if omitted)
#[arg(long, value_enum)]
format: Option<ClassifyFormat>,
},
/// Apply auto-fixes to shell scripts (SSC v11 S8.1, Linter Spec S9)
Fix {
/// Input file(s) to fix
#[arg(value_name = "FILE", required = true, num_args = 1..)]
input: Vec<PathBuf>,
/// Preview fixes without applying them
#[arg(long)]
dry_run: bool,
/// Include SAFE-WITH-ASSUMPTIONS fixes (default: SAFE only)
#[arg(long)]
assumptions: bool,
/// Write fixed output to a different file (single input only)
#[arg(short, long)]
output: Option<PathBuf>,
/// Path to chat model directory for ML-powered fix suggestions (requires `ml` feature)
#[arg(long, value_name = "DIR")]
chat_model: Option<PathBuf>,
},
/// Explain script safety with detailed natural-language analysis (SSC v11 S8.1)
Explain {
/// Input script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output as JSON
#[arg(long)]
json: bool,
/// Force format (auto-detected from extension if omitted)
#[arg(long, value_enum)]
format: Option<ClassifyFormat>,
/// Path to chat model directory for ML-powered explanation (requires `ml` feature)
#[arg(long, value_name = "DIR")]
chat_model: Option<PathBuf>,
},
/// Classify script safety (supports bash, Makefile, Dockerfile)
Classify {
/// Input script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output as JSON
#[arg(long)]
json: bool,
/// Multi-label mode: show all applicable labels, not just the primary one
#[arg(long)]
multi_label: bool,
/// Force format (auto-detected from extension if omitted)
#[arg(long, value_enum)]
format: Option<ClassifyFormat>,
/// Path to trained linear probe weights (probe.json from train-classifier)
#[arg(long)]
probe: Option<std::path::PathBuf>,
/// Path to trained MLP probe weights (mlp_probe.json from train-classifier --mlp)
#[arg(long)]
mlp_probe: Option<std::path::PathBuf>,
/// Path to CodeBERT model directory (for Stage 1 ML classification with --probe or --mlp-probe)
#[arg(long)]
model: Option<std::path::PathBuf>,
},
/// Makefile parsing, purification, and transformation
Make {
#[command(subcommand)]
command: MakeCommands,
},
/// Dockerfile purification and linting (NEW in v6.36.0)
Dockerfile {
#[command(subcommand)]
command: DockerfileCommands,
},
/// Dev Container validation (devcontainer.json) (NEW in v6.43.0)
Devcontainer {
#[command(subcommand)]
command: DevContainerCommands,
},
/// Shell artifact compliance system (NEW in v7.1.0 - SPEC-COMPLY-2026-001)
Comply {
#[command(subcommand)]
command: ComplyCommands,
},
/// V2 corpus scoring and quality measurement (NEW in v7.2.0)
Corpus {
#[command(subcommand)]
command: CorpusCommands,
},
/// Shell configuration file management (NEW in v7.0)
Config {
#[command(subcommand)]
command: ConfigCommands,
},
/// Interactive REPL with integrated debugger (NEW in v7.0)
Repl {
/// Enable debug mode
#[arg(long)]
debug: bool,
/// Enable sandboxed execution
#[arg(long)]
sandboxed: bool,
/// Maximum memory usage in MB (default: 100)
#[arg(long)]
max_memory: Option<usize>,
/// Timeout in seconds (default: 30)
#[arg(long)]
timeout: Option<u64>,
/// Maximum recursion depth (default: 100)
#[arg(long)]
max_depth: Option<usize>,
},
/// Terminal User Interface with multi-panel layout (NEW)
#[cfg(feature = "tui")]
Tui,
/// Enforce quality gates (NEW in v6.42.0)
Gate {
/// Quality gate tier (1=fast, 2=pre-commit, 3=nightly)
#[arg(long, default_value = "1")]
tier: u8,
/// Report format
#[arg(long, value_enum, default_value = "human")]
report: ReportFormat,
},
/// Run bash script tests (NEW in v6.10.0 - Bash Quality Tools)
Test {
/// Input bash script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: TestOutputFormat,
/// Show detailed test results
#[arg(long)]
detailed: bool,
/// Run only tests matching pattern
#[arg(long)]
pattern: Option<String>,
},
/// Score bash script quality (NEW in v6.11.0 - Bash Quality Tools)
Score {
/// Input bash script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: ScoreOutputFormat,
/// Show detailed dimension scores
#[arg(long)]
detailed: bool,
/// Use Dockerfile-specific quality scoring
#[arg(long)]
dockerfile: bool,
/// Include runtime performance metrics in score (requires Docker daemon for Dockerfiles)
#[arg(long)]
runtime: bool,
/// Show letter grade (A+, A, B+, B, C+, C, D, F)
#[arg(long)]
grade: bool,
/// Apply platform-specific scoring profile (coursera)
#[arg(long, value_enum)]
profile: Option<LintProfileArg>,
},
/// Run comprehensive quality audit (NEW in v6.12.0 - Bash Quality Tools)
Audit {
/// Input bash script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: AuditOutputFormat,
/// Enable strict mode (fail on warnings)
#[arg(long)]
strict: bool,
/// Show detailed check results
#[arg(long)]
detailed: bool,
/// Minimum grade required (A+, A, B+, B, C+, C, D, F)
#[arg(long)]
min_grade: Option<String>,
},
/// Generate coverage report (NEW in v6.13.0 - Bash Quality Tools)
Coverage {
/// Input bash script file
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "terminal")]
format: CoverageOutputFormat,
/// Minimum coverage percentage required
#[arg(long)]
min: Option<u8>,
/// Show detailed coverage breakdown
#[arg(long)]
detailed: bool,
/// Output file for HTML/LCOV format
#[arg(short, long)]
output: Option<PathBuf>,
},
/// Format bash scripts (NEW in v6.14.0 - Bash Quality Tools)
Format {
/// Input bash script file(s)
#[arg(value_name = "FILE", required = true)]
inputs: Vec<PathBuf>,
/// Check if files are formatted without applying changes
#[arg(long)]
check: bool,
/// Show diff without applying changes
#[arg(long)]
dry_run: bool,
/// Output file (for single input file)
#[arg(short, long)]
output: Option<PathBuf>,
},
#[command(flatten)]
Ext(super::args_ext::CommandsExt),
}
include!("args_valueenum.rs");