feat(clean): add --trash option to move cleaned files to Trash instead of deleting#442
Closed
spider-yamet wants to merge 1 commit intotw93:mainfrom
Closed
feat(clean): add --trash option to move cleaned files to Trash instead of deleting#442spider-yamet wants to merge 1 commit intotw93:mainfrom
spider-yamet wants to merge 1 commit intotw93:mainfrom
Conversation
Owner
|
@spider-yamet Thanks for the suggestion and for taking the time to describe the use case. After reviewing this, we will not plan this feature for now. Reasoning:
So for now, we keep the current safety model: preview first ( We may revisit this in the future if we can provide a strict and fully predictable Trash-only workflow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an option to move cleaned files to the system Trash instead of permanently removing them, so users can recover items if needed.
Closes #439
Changes
lib/core/file_ops.shsafe_move_to_trash()that uses macOS Finder (osascript) to move paths to Trash.MOLE_USE_TRASH=1,safe_remove()tries trash first and falls back tormif trash fails (e.g. headless or permission).--trashis used.bin/clean.sh--trash/-tflag and setMOLE_USE_TRASH=1.--trash.lib/core/help.sh--trash, -tin clean help.Usage
mo clean --dry-run— preview (no changes)mo clean --dry-run --trash— preview move to Trashmo clean --trash— clean and move items to Trashmo clean— default: permanent removal (unchanged)Notes
safe_remove().safe_sudo_remove()(system paths) is unchanged and still permanently removes.Testing
tests/cli.bats:mo clean --helpshows--trash.tests/clean_core.bats:mo clean --dry-run --trashdoes not delete files.tests/core_safe_functions.bats:safe_removewithMOLE_USE_TRASH=1removes the file (trash or fallback).