Skip to content

Commit 8a4685f

Browse files
committed
cargo-rail: cleaning cli artifacts post-refactor.
1 parent 09a86c2 commit 8a4685f

File tree

10 files changed

+118
-178
lines changed

10 files changed

+118
-178
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ demos/
2929
test.md
3030
examples/RECORDING_TEMPLATE.md
3131
examples/issues.md
32+
commands_check.md
3233

3334
# Cargo-Rail (Testing)
3435
*rail.toml

docs/commands.md

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Commands:
2121
split Split a crate to a standalone repository with git history
2222
sync Sync changes between monorepo and split repos
2323
release Publish releases (version bump, changelog, tag, publish)
24-
check Validate release readiness
24+
check Reserved for future use
2525
clean Clean generated artifacts (cache, backups, reports)
2626
config Configuration management
2727
help Print this message or the help of the given subcommand(s)
@@ -211,7 +211,7 @@ Examples:
211211
cargo rail unify --check # Preview changes (CI mode)
212212
cargo rail unify # Apply changes
213213
cargo rail unify --backup # Apply with backup
214-
cargo rail unify --pin-transitives # Pin fragmented deps (hakari replacement)
214+
cargo rail unify --show-diff # Show manifest changes
215215
cargo rail unify undo # Restore from backup
216216
cargo rail unify undo --list # List available backups
217217
```
@@ -258,9 +258,6 @@ Options:
258258
--json
259259
Output in JSON format (shorthand for -f json)
260260
261-
--non-interactive
262-
Skip interactive prompts
263-
264261
-c, --check
265262
Dry-run mode: preview generated config without writing
266263
@@ -271,8 +268,7 @@ Options:
271268
Print version
272269
273270
Examples:
274-
cargo rail init # Generate .config/rail.toml (interactive)
275-
cargo rail init --non-interactive # Generate with defaults (CI mode)
271+
cargo rail init # Generate .config/rail.toml
276272
cargo rail init --check # Preview generated config
277273
cargo rail init -o rail.toml # Custom output path
278274
cargo rail init --force # Overwrite existing config
@@ -425,9 +421,6 @@ Options:
425421
426422
[default: manual]
427423
428-
--no-protected-branches
429-
Allow direct commits to protected branches
430-
431424
-c, --check
432425
Dry-run mode: preview changes without executing
433426
@@ -467,9 +460,10 @@ Publish releases (version bump, changelog, tag, publish)
467460
Usage: cargo rail release [OPTIONS] <COMMAND>
468461
469462
Commands:
470-
init Configure release settings
471-
run Execute release (plan or publish)
472-
help Print this message or the help of the given subcommand(s)
463+
init Configure release settings
464+
run Execute release (plan or publish)
465+
check Validate release readiness
466+
help Print this message or the help of the given subcommand(s)
473467
474468
Options:
475469
-q, --quiet
@@ -486,6 +480,8 @@ Options:
486480
487481
Examples:
488482
cargo rail release init my-crate # Configure release for my-crate
483+
cargo rail release check my-crate # Validate release readiness
484+
cargo rail release check --all # Check all workspace crates
489485
cargo rail release run my-crate --check # Preview release plan
490486
cargo rail release run my-crate # Release (patch bump)
491487
cargo rail release run my-crate --bump minor
@@ -572,12 +568,12 @@ Options:
572568

573569
---
574570

575-
## cargo rail check
571+
### cargo rail release check
576572

577573
```
578574
Validate release readiness
579575
580-
Usage: cargo rail check [OPTIONS] [CRATE_NAMES]...
576+
Usage: cargo rail release check [OPTIONS] [CRATE_NAMES]...
581577
582578
Arguments:
583579
[CRATE_NAMES]...
@@ -611,12 +607,33 @@ Options:
611607
612608
-V, --version
613609
Print version
610+
```
614611

615-
Examples:
616-
cargo rail check my-crate # Check single crate
617-
cargo rail check crate-a crate-b # Check multiple crates
618-
cargo rail check --all # Check all workspace crates
619-
cargo rail check --all -f json # JSON output for CI
612+
---
613+
614+
## cargo rail check
615+
616+
```
617+
Reserved for future use
618+
619+
Usage: cargo rail check [OPTIONS]
620+
621+
Options:
622+
-q, --quiet
623+
Suppress progress messages (for CI/automation)
624+
625+
--json
626+
Output in JSON format (shorthand for -f json)
627+
628+
-h, --help
629+
Print help (see a summary with '-h')
630+
631+
-V, --version
632+
Print version
633+
634+
Reserved for future use.
635+
636+
This command is currently a placeholder. Use 'cargo rail release check' instead.
620637
```
621638

622639
---
@@ -675,10 +692,21 @@ Commands:
675692
help Print this message or the help of the given subcommand(s)
676693
677694
Options:
678-
-q, --quiet Suppress progress messages (for CI/automation)
679-
--json Output in JSON format (shorthand for -f json)
680-
-h, --help Print help
681-
-V, --version Print version
695+
-q, --quiet
696+
Suppress progress messages (for CI/automation)
697+
698+
--json
699+
Output in JSON format (shorthand for -f json)
700+
701+
-h, --help
702+
Print help (see a summary with '-h')
703+
704+
-V, --version
705+
Print version
706+
707+
Examples:
708+
cargo rail config validate # Validate rail.toml
709+
cargo rail config validate -f json # JSON output for CI
682710
```
683711

684712
---

src/commands/cli.rs

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ Examples:
9898
const RELEASE_HELP: &str = "\
9999
Examples:
100100
cargo rail release init my-crate # Configure release for my-crate
101+
cargo rail release check my-crate # Validate release readiness
102+
cargo rail release check --all # Check all workspace crates
101103
cargo rail release run my-crate --check # Preview release plan
102104
cargo rail release run my-crate # Release (patch bump)
103105
cargo rail release run my-crate --bump minor
@@ -106,18 +108,15 @@ Examples:
106108

107109
const INIT_HELP: &str = "\
108110
Examples:
109-
cargo rail init # Generate .config/rail.toml (interactive)
110-
cargo rail init --non-interactive # Generate with defaults (CI mode)
111+
cargo rail init # Generate .config/rail.toml
111112
cargo rail init --check # Preview generated config
112113
cargo rail init -o rail.toml # Custom output path
113114
cargo rail init --force # Overwrite existing config";
114115

115116
const CHECK_HELP: &str = "\
116-
Examples:
117-
cargo rail check my-crate # Check single crate
118-
cargo rail check crate-a crate-b # Check multiple crates
119-
cargo rail check --all # Check all workspace crates
120-
cargo rail check --all -f json # JSON output for CI";
117+
Reserved for future use.
118+
119+
This command is currently a placeholder. Use 'cargo rail release check' instead.";
121120

122121
const CLEAN_HELP: &str = "\
123122
Examples:
@@ -219,9 +218,6 @@ pub enum Commands {
219218
/// Overwrite existing configuration
220219
#[arg(long)]
221220
force: bool,
222-
/// Skip interactive prompts
223-
#[arg(long)]
224-
non_interactive: bool,
225221
/// Dry-run mode: preview generated config without writing
226222
#[arg(long, short = 'c')]
227223
check: bool,
@@ -256,9 +252,6 @@ pub enum Commands {
256252
/// Conflict resolution strategy
257253
#[arg(long, default_value_t, value_enum)]
258254
strategy: ConflictStrategy,
259-
/// Allow direct commits to protected branches
260-
#[arg(long)]
261-
no_protected_branches: bool,
262255
/// Dry-run mode: preview changes without executing
263256
#[arg(long, short = 'c')]
264257
check: bool,
@@ -275,19 +268,9 @@ pub enum Commands {
275268
command: ReleaseCommand,
276269
},
277270

278-
/// Validate release readiness
271+
/// Reserved for future use
279272
#[command(after_long_help = CHECK_HELP)]
280-
Check {
281-
/// Crate name(s) to check (mutually exclusive with --all)
282-
#[arg(conflicts_with = "all")]
283-
crate_names: Vec<String>,
284-
/// Check all workspace crates (mutually exclusive with crate names)
285-
#[arg(short, long)]
286-
all: bool,
287-
/// Output format
288-
#[arg(long, short = 'f', default_value_t, value_enum)]
289-
format: OutputFormat,
290-
},
273+
Check {},
291274

292275
/// Clean generated artifacts (cache, backups, reports)
293276
#[command(after_long_help = CLEAN_HELP)]
@@ -407,6 +390,18 @@ pub enum ReleaseCommand {
407390
#[arg(long, short = 'f', default_value_t, value_enum)]
408391
format: OutputFormat,
409392
},
393+
/// Validate release readiness
394+
Check {
395+
/// Crate name(s) to check (mutually exclusive with --all)
396+
#[arg(conflicts_with = "all")]
397+
crate_names: Vec<String>,
398+
/// Check all workspace crates (mutually exclusive with crate names)
399+
#[arg(short, long)]
400+
all: bool,
401+
/// Output format
402+
#[arg(long, short = 'f', default_value_t, value_enum)]
403+
format: OutputFormat,
404+
},
410405
}
411406

412407
fn get_styles() -> clap::builder::Styles {
@@ -423,15 +418,14 @@ impl Commands {
423418
Commands::Affected { format, .. }
424419
| Commands::Test { format, .. }
425420
| Commands::Unify { format, .. }
426-
| Commands::Sync { format, .. }
427-
| Commands::Check { format, .. } => format.is_json_like(),
421+
| Commands::Sync { format, .. } => format.is_json_like(),
428422
Commands::Split { command } => match command {
429423
SplitCommand::Init { .. } => false,
430424
SplitCommand::Run { format, .. } => format.is_json_like(),
431425
},
432426
Commands::Release { command } => match command {
433427
ReleaseCommand::Init { .. } => false,
434-
ReleaseCommand::Run { format, .. } => format.is_json_like(),
428+
ReleaseCommand::Run { format, .. } | ReleaseCommand::Check { format, .. } => format.is_json_like(),
435429
},
436430
Commands::Config { command } => match command {
437431
ConfigCommand::Validate { format } => format.is_json_like(),
@@ -446,14 +440,13 @@ impl Commands {
446440
Commands::Affected { format, .. }
447441
| Commands::Test { format, .. }
448442
| Commands::Unify { format, .. }
449-
| Commands::Sync { format, .. }
450-
| Commands::Check { format, .. } => *format = OutputFormat::Json,
443+
| Commands::Sync { format, .. } => *format = OutputFormat::Json,
451444
Commands::Split {
452445
command: SplitCommand::Run { format, .. },
453446
} => *format = OutputFormat::Json,
454447
Commands::Split { .. } => {}
455448
Commands::Release {
456-
command: ReleaseCommand::Run { format, .. },
449+
command: ReleaseCommand::Run { format, .. } | ReleaseCommand::Check { format, .. },
457450
} => *format = OutputFormat::Json,
458451
Commands::Release { .. } => {}
459452
Commands::Config { command } => match command {

src/commands/init.rs

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,11 @@ use crate::progress;
99
use crate::toml::builder::RailConfigBuilder;
1010
use crate::workspace::WorkspaceContext;
1111
use std::fs;
12-
use std::io::{self, Write};
1312
use std::path::{Path, PathBuf};
1413

1514
/// Generate rail.toml configuration
16-
pub fn run_init(
17-
ctx: &WorkspaceContext,
18-
output_path: &str,
19-
force: bool,
20-
non_interactive: bool,
21-
check: bool,
22-
) -> RailResult<()> {
23-
run_init_impl(ctx.workspace_root(), output_path, force, non_interactive, check)
15+
pub fn run_init(ctx: &WorkspaceContext, output_path: &str, force: bool, check: bool) -> RailResult<()> {
16+
run_init_impl(ctx.workspace_root(), output_path, force, check)
2417
}
2518

2619
/// Auto-detect reasonable unify defaults
@@ -83,13 +76,7 @@ fn write_config_file(config_path: &Path, content: &str) -> RailResult<()> {
8376
}
8477

8578
/// Shared implementation for both run_init and run_init_standalone
86-
fn run_init_impl(
87-
workspace_root: &Path,
88-
output_path: &str,
89-
force: bool,
90-
non_interactive: bool,
91-
check: bool,
92-
) -> RailResult<()> {
79+
fn run_init_impl(workspace_root: &Path, output_path: &str, force: bool, check: bool) -> RailResult<()> {
9380
let config_path = workspace_root.join(output_path);
9481

9582
// Check if target path already exists
@@ -111,30 +98,6 @@ fn run_init_impl(
11198
}
11299

113100
let detected_targets = detect_targets(workspace_root);
114-
115-
if !non_interactive && !check {
116-
// Show preview before confirmation
117-
eprintln!("output: {}", config_path.display());
118-
if detected_targets.is_empty() {
119-
eprintln!("targets: (none detected, will use host default)");
120-
} else {
121-
eprintln!("targets: {}", detected_targets.join(", "));
122-
}
123-
eprintln!();
124-
125-
eprint!("generate? [Y/n]: ");
126-
io::stderr().flush()?;
127-
128-
let mut input = String::new();
129-
io::stdin().read_line(&mut input)?;
130-
let input = input.trim().to_lowercase();
131-
132-
if input == "n" || input == "no" {
133-
eprintln!("cancelled");
134-
return Ok(());
135-
}
136-
}
137-
138101
let config = build_rail_config(detected_targets);
139102

140103
let toml_content = RailConfigBuilder::new()
@@ -159,14 +122,8 @@ fn run_init_impl(
159122
}
160123

161124
/// Standalone init (without WorkspaceContext)
162-
pub fn run_init_standalone(
163-
workspace_root: &Path,
164-
output_path: &str,
165-
force: bool,
166-
non_interactive: bool,
167-
check: bool,
168-
) -> RailResult<()> {
169-
run_init_impl(workspace_root, output_path, force, non_interactive, check)
125+
pub fn run_init_standalone(workspace_root: &Path, output_path: &str, force: bool, check: bool) -> RailResult<()> {
126+
run_init_impl(workspace_root, output_path, force, check)
170127
}
171128

172129
#[cfg(test)]

0 commit comments

Comments
 (0)