Expand description
Remove files or directories passed as CLI args (recursive for dirs).
Strips trailing metadata suffix beginning at the first ‘:’ in each argument (colon and suffix removed) before
deletion. Useful when piping annotated paths (e.g. from linters or search tools emitting path:line:col).
§Arguments
<paths...>One or more filesystem paths (files, symlinks, or directories). Optional trailing:...suffix is removed.
§Returns
- Exit code 0 if all provided paths were deleted successfully (or no paths given).
- Exit code 1 if any path failed to delete or did not exist.
§Errors
- Initialization failure from
color_eyre::install. - I/O errors from
std::fs::remove_fileorstd::fs::remove_dir_all. These are reported individually and contribute to a non-zero exit code.
§Rationale
- Eliminates need for ad-hoc shell loops to mass-delete mixed file & directory sets while handling
tool:line:colstyle suffixes. - Colorized error reporting highlights problematic paths quickly.
§Performance
- One reverse byte scan per argument to locate last ‘:’ (no allocation).
- Single
symlink_metadatacall per path (branches onstd::fs::FileType), minimizing metadata syscalls. - Sequential deletions avoid contention; for huge argument lists, parallelism could help but increases complexity (ordering, error aggregation).
§Future Work
- Add
--dry-runflag for previewing deletions. - Add parallel deletion (configurable) for large batches.
- Accept glob patterns expanded internally (on platforms without shell globbing).
Functions§
- before_
first_ 🔒colon - Strips suffix beginning at first ‘:’; returns subslice before colon.
- main 🔒
- Remove files or directories passed as CLI args (recursive for dirs).
- process 🔒
- Deletes one path after stripping the first ‘:’ suffix segment.