1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-23 19:20:07 +00:00

Support debug

This commit is contained in:
Tw93
2025-12-05 17:16:46 +08:00
parent 5761fd87c8
commit b939442e92
11 changed files with 160 additions and 30 deletions

39
mole
View File

@@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/core/common.sh"
# Version info
VERSION="1.11.24"
VERSION="1.11.25"
MOLE_TAGLINE="can dig deep to clean your Mac."
# Check if Touch ID is already configured
@@ -174,6 +174,9 @@ show_help() {
printf " %s%-28s%s %s\n" "$GREEN" "mo --version" "$NC" "Show version"
printf " %s%-28s%s %s\n" "$GREEN" "mo --help" "$NC" "Show help"
echo
printf "%s%s%s\n" "$BLUE" "OPTIONS" "$NC"
printf " %s%-28s%s %s\n" "$GREEN" "--debug" "$NC" "Show detailed debug logs"
echo
}
# Simple update function
@@ -672,24 +675,42 @@ interactive_main_menu() {
}
main() {
case "${1:-""}" in
# Parse global flags from any position in arguments
local -a args=()
for arg in "$@"; do
case "$arg" in
--debug)
export MO_DEBUG=1
;;
*)
args+=("$arg")
;;
esac
done
# Show debug indicator if enabled
if [[ "${MO_DEBUG:-}" == "1" && -t 2 ]]; then
echo -e "${GRAY}[DEBUG MODE ENABLED]${NC}" >&2
fi
case "${args[0]:-""}" in
"optimize")
exec "$SCRIPT_DIR/bin/optimize.sh"
exec "$SCRIPT_DIR/bin/optimize.sh" "${args[@]:1}"
;;
"clean")
exec "$SCRIPT_DIR/bin/clean.sh" "${@:2}"
exec "$SCRIPT_DIR/bin/clean.sh" "${args[@]:1}"
;;
"uninstall")
exec "$SCRIPT_DIR/bin/uninstall.sh"
exec "$SCRIPT_DIR/bin/uninstall.sh" "${args[@]:1}"
;;
"analyze")
exec "$SCRIPT_DIR/bin/analyze.sh" "${@:2}"
exec "$SCRIPT_DIR/bin/analyze.sh" "${args[@]:1}"
;;
"status")
exec "$SCRIPT_DIR/bin/status.sh" "${@:2}"
exec "$SCRIPT_DIR/bin/status.sh" "${args[@]:1}"
;;
"touchid")
exec "$SCRIPT_DIR/bin/touchid.sh" "${@:2}"
exec "$SCRIPT_DIR/bin/touchid.sh" "${args[@]:1}"
;;
"update")
update_mole
@@ -711,7 +732,7 @@ main() {
interactive_main_menu
;;
*)
echo "Unknown command: $1"
echo "Unknown command: ${args[0]}"
echo "Use 'mole --help' for usage information."
exit 1
;;