1.7 KiB
1.7 KiB
Quickstart: Remove Command with Sequential Multi-Pattern Support
Goal
Demonstrate how to delete multiple substrings sequentially from filenames while using the preview → apply → undo workflow safely.
Prerequisites
- Go toolchain (>= 1.24) installed for building the CLI locally.
- Sample directory containing files with recurring tokens (e.g.,
draft,copy).
Steps
-
Build the CLI
go build -o renamer ./... -
Inspect remove help
./renamer remove --helpPay attention to sequential behavior: tokens execute in the order provided.
-
Run a preview with multiple tokens
./renamer remove " copy" " draft" --path ./samples --dry-runConfirm the output table shows each token removed in order and the summary reflects changed files.
-
Apply removals after review
./renamer remove " copy" " draft" --path ./samples --yesVerify filenames no longer contain the tokens and a ledger entry is created.
-
Undo if necessary
./renamer undo --path ./samplesEnsure filenames return to their original state.
-
Handle empty-result warnings
./renamer remove "project" "project-" --path ./samples --dry-runExpect the preview to warn and skip items that would collapse to empty names.
-
Integrate into automation
./renamer remove foo bar --dry-run && \ ./renamer remove foo bar --yes --path ./automationUse non-zero exit codes to detect invalid input in scripts.
Next Steps
- Add contract tests covering sequential removals and empty-name warnings.
- Extend documentation (CLI reference, changelog) with remove command examples.