1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-16 21:04:11 +00:00

🎨 Dry mode is easy to use

This commit is contained in:
Tw93
2025-10-03 13:56:34 +08:00
parent 428f5e9652
commit 4047a0b035

View File

@@ -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"
@@ -898,7 +906,7 @@ main() {
echo "Options:" echo "Options:"
echo " --help, -h Show this help" echo " --help, -h Show this help"
echo " --dry-run, -n Preview what would be cleaned without deleting" echo " --dry-run, -n Preview what would be cleaned without deleting"
echo " --whitelist Show active whitelist patterns" echo " --whitelist Show active whitelist patterns"
echo "" echo ""
echo "Interactive cleanup with smart password handling" echo "Interactive cleanup with smart password handling"
echo "" echo ""