Problem
Only clean and push commands have --dry-run mode. Other destructive operations lack preview capability, making them risky.
Missing Dry-Run Support
reset --hard - No preview of what will be reverted
revert - No preview of changes
merge - No preview of merge outcome
checkout - No preview of file changes
restore - No preview of what will be restored
Impact
- Risky operations without preview
- Users can't verify effects before executing
- Increased chance of accidental data loss
- Poor UX compared to modern tools
Approach
1. Add --dry-run Flag:
#[derive(Parser)]
pub struct ResetArgs {
#[arg(long)]
dry_run: bool,
// ... other args
}
2. Implement Preview Logic:
if args.dry_run {
// Show what would happen
println!("Would reset the following files:");
for file in files_to_reset {
println!(" {}", file.display());
}
println!("\nRun without --dry-run to execute");
return Ok(());
}
3. Preview Information:
- Files that would be modified
- Files that would be deleted
- Unstaged/uncommitted changes that would be lost
- Commit range that would be affected
4. Consistent Output Format:
Create helper for dry-run output:
fn preview_changes(action: &str, files: &[PathBuf]) {
println!("{}: {} files would be {}",
"Dry run".yellow().bold(),
files.len(),
action);
for file in files {
println!(" {} {}", "→".dim(), file.display());
}
}
Priority by Command
- High:
reset --hard (most destructive)
- High:
checkout (can overwrite files)
- Medium:
revert, merge (complex operations)
- Low:
restore (usually intentional)
Test Cases
- Each command with
--dry-run shows preview
- Verify no actual changes made in dry-run mode
- Verify same logic used for preview and execution
References
rsync --dry-run as gold standard
git rm --dry-run, git clean --dry-run
- Consider adding
--interactive mode for some commands
Problem
Only
cleanandpushcommands have--dry-runmode. Other destructive operations lack preview capability, making them risky.Missing Dry-Run Support
reset --hard- No preview of what will be revertedrevert- No preview of changesmerge- No preview of merge outcomecheckout- No preview of file changesrestore- No preview of what will be restoredImpact
Approach
1. Add --dry-run Flag:
2. Implement Preview Logic:
3. Preview Information:
4. Consistent Output Format:
Create helper for dry-run output:
Priority by Command
reset --hard(most destructive)checkout(can overwrite files)revert,merge(complex operations)restore(usually intentional)Test Cases
--dry-runshows previewReferences
rsync --dry-runas gold standardgit rm --dry-run,git clean --dry-run--interactivemode for some commands