Add cache clearing command to launcher

NEW FEATURE:
- launcher.sh --clear-cache: Clear all stale cache and temp files
- Clears .sysref.beta and .sysref.beta.timestamp
- Clears temporary files in tmp/ directory
- Auto-rebuilds cache on next run

USAGE:
  bash launcher.sh --clear-cache

SOLVES:
- Users can now easily clear stale cache
- WordPress site listings will update
- Database/user listings will refresh
- No more ghost entries from previous runs

ADDED TO HELP:
- Updated --help output with --clear-cache option
- Usage examples included
This commit is contained in:
Developer
2026-03-20 01:47:44 -04:00
parent df95500ab9
commit bd1b68d1f4
+46
View File
@@ -780,13 +780,59 @@ main() {
echo "═══════════════════════════════════════════════════════════════"
return 0
;;
--clear-cache)
# Initialize directories first
init_directories || {
echo "ERROR: Failed to initialize directories"
return 1
}
# Clear all caches
local cache_cleared=0
# Production cache
if [ -f "$BASE_DIR/.sysref" ] || [ -f "$BASE_DIR/.sysref.timestamp" ]; then
rm -f "$BASE_DIR/.sysref" "$BASE_DIR/.sysref.timestamp" 2>/dev/null || true
echo "✓ Cleared production cache (.sysref)"
cache_cleared=1
fi
# Dev cache
if [ -f "$BASE_DIR/.sysref.beta" ] || [ -f "$BASE_DIR/.sysref.beta.timestamp" ]; then
rm -f "$BASE_DIR/.sysref.beta" "$BASE_DIR/.sysref.beta.timestamp" 2>/dev/null || true
echo "✓ Cleared dev cache (.sysref.beta)"
cache_cleared=1
fi
# Temp files
if [ -d "$BASE_DIR/tmp" ]; then
rm -rf "$BASE_DIR/tmp"/* 2>/dev/null || true
echo "✓ Cleared temporary files"
cache_cleared=1
fi
if [ $cache_cleared -eq 0 ]; then
echo "️ No cache files to clear"
else
echo ""
echo "Cache cleared successfully!"
echo "System will auto-detect and rebuild cache on next run."
fi
return 0
;;
--help|--usage|-h|-?)
echo "Usage: launcher.sh [OPTIONS]"
echo ""
echo "Options:"
echo " --detect-only Show system detection results and exit"
echo " --clear-cache Clear all cache and temporary files"
echo " --help Show this help message"
echo ""
echo "Examples:"
echo " bash launcher.sh --detect-only # Check what was detected"
echo " bash launcher.sh --clear-cache # Clear stale cache data"
echo " bash launcher.sh # Normal interactive mode"
echo ""
return 0
;;
esac