mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 16:25:17 +00:00
🎨 Dry mode is easy to use
This commit is contained in:
16
bin/clean.sh
16
bin/clean.sh
@@ -17,7 +17,12 @@ WHITELIST_PATTERNS=("$HOME/Library/Caches/ms-playwright*")
|
|||||||
# Load user-defined whitelist file if present (~/.config/mole/whitelist)
|
# Load user-defined whitelist file if present (~/.config/mole/whitelist)
|
||||||
if [[ -f "$HOME/.config/mole/whitelist" ]]; then
|
if [[ -f "$HOME/.config/mole/whitelist" ]]; then
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
|
# Trim leading/trailing whitespace without relying on external tools
|
||||||
|
line="${line#${line%%[![:space:]]*}}"
|
||||||
|
line="${line%${line##*[![:space:]]}}"
|
||||||
[[ -z "$line" || "$line" =~ ^# ]] && continue
|
[[ -z "$line" || "$line" =~ ^# ]] && continue
|
||||||
|
# Expand leading ~ for user convenience
|
||||||
|
[[ "$line" == ~* ]] && line="${line/#~/$HOME}"
|
||||||
WHITELIST_PATTERNS+=("$line")
|
WHITELIST_PATTERNS+=("$line")
|
||||||
done < "$HOME/.config/mole/whitelist"
|
done < "$HOME/.config/mole/whitelist"
|
||||||
fi
|
fi
|
||||||
@@ -252,26 +257,29 @@ safe_clean() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_cleanup() {
|
start_cleanup() {
|
||||||
|
echo ""
|
||||||
echo "Mole will remove app caches, browser data, developer tools, and temporary files."
|
echo "Mole will remove app caches, browser data, developer tools, and temporary files."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
if [[ "$DRY_RUN" != "true" && -t 0 ]]; then
|
||||||
|
echo -e "${BLUE}Tip:${NC} Want a preview first? Run 'mole clean --dry-run'."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$DRY_RUN" == "true" ]]; then
|
if [[ "$DRY_RUN" == "true" ]]; then
|
||||||
echo -e "${YELLOW}🧪 Dry Run mode:${NC} showing what would be removed (no deletions)."
|
echo -e "${YELLOW}🧪 Dry Run mode:${NC} showing what would be removed (no deletions)."
|
||||||
echo ""
|
echo ""
|
||||||
password=""
|
|
||||||
SYSTEM_CLEAN=false
|
SYSTEM_CLEAN=false
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if we're in an interactive terminal
|
local password=""
|
||||||
if [[ -t 0 ]]; then
|
if [[ -t 0 ]]; then
|
||||||
# Interactive mode - ask for password
|
|
||||||
echo "Enter admin password for system-level cleanup (or press Enter to skip):"
|
echo "Enter admin password for system-level cleanup (or press Enter to skip):"
|
||||||
echo -n "> "
|
echo -n "> "
|
||||||
read -s password
|
read -s password
|
||||||
echo ""
|
echo ""
|
||||||
else
|
else
|
||||||
# Non-interactive mode - skip password prompt
|
|
||||||
password=""
|
password=""
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${BLUE}ℹ${NC} Running in non-interactive mode"
|
echo -e "${BLUE}ℹ${NC} Running in non-interactive mode"
|
||||||
|
|||||||
Reference in New Issue
Block a user