diff --git a/README.md b/README.md index 043f444..a6240f4 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ mo optimize # Refresh caches & services mo analyze # Visual disk explorer mo status # Live system health dashboard mo purge # Clean project build artifacts -mo installers # Find and remove installer files +mo installer # Find and remove installer files mo touchid # Configure Touch ID for sudo mo completion # Setup shell tab completion diff --git a/bin/installers.sh b/bin/installer.sh similarity index 90% rename from bin/installers.sh rename to bin/installer.sh index 2f788cb..8c2d00c 100755 --- a/bin/installers.sh +++ b/bin/installer.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Mole - Installers command -# Highlights and helps remove installer files (.dmg, .pkg, .mpkg, .iso, .xip, .zip) +# Mole - Installer command +# Find and remove installer files (.dmg, .pkg, .mpkg, .iso, .xip, .zip) set -euo pipefail @@ -270,37 +270,15 @@ show_summary() { printf '\n' } -show_help() { - echo -e "${PURPLE_BOLD}Mole Installers${NC} - Find and remove installer files" - echo "" - echo -e "${YELLOW}Usage:${NC} mo installers [options]" - echo "" - echo -e "${YELLOW}Options:${NC}" - echo " --debug Enable debug logging" - echo " --help Show this help message" - echo "" - echo -e "${YELLOW}Default Paths${NC}" - echo " - ${HOME}/Downloads" - echo " - ${HOME}/Desktop" - echo " - ${HOME}/Documents" - echo " - ${HOME}/Public" - echo " - ${HOME}/Library/Downloads" - echo " - /Users/Shared" -} main() { for arg in "$@"; do case "$arg" in - "--help") - show_help - exit 0 - ;; "--debug") export MO_DEBUG=1 ;; *) echo "Unknown option: $arg" - echo "Use 'mo installers --help' for usage information" exit 1 ;; esac @@ -311,7 +289,7 @@ main() { printf '\033[2J\033[H' fi printf '\n' - echo -e "${PURPLE_BOLD}Find & Remove Installers${NC}" + echo -e "${PURPLE_BOLD}Clean Installer Files${NC}" hide_cursor perform_installers diff --git a/lib/core/commands.sh b/lib/core/commands.sh index c0eaa9e..3d2559e 100644 --- a/lib/core/commands.sh +++ b/lib/core/commands.sh @@ -8,7 +8,7 @@ MOLE_COMMANDS=( "analyze:Explore disk usage" "status:Monitor system health" "purge:Remove old project artifacts" - "installers:Find and remove installer files" + "installer:Find and remove installer files" "touchid:Configure Touch ID for sudo" "completion:Setup shell tab completion" "update:Update to latest version" diff --git a/mole b/mole index 63d2292..a40c37c 100755 --- a/mole +++ b/mole @@ -222,7 +222,6 @@ show_help() { printf " %s%-28s%s %s\n" "$GREEN" "mo optimize --dry-run" "$NC" "Preview optimization" printf " %s%-28s%s %s\n" "$GREEN" "mo optimize --whitelist" "$NC" "Manage protected items" printf " %s%-28s%s %s\n" "$GREEN" "mo purge --paths" "$NC" "Configure scan directories" - printf " %s%-28s%s %s\n" "$GREEN" "mo installers --debug" "$NC" "Find installer files" echo printf "%s%s%s\n" "$BLUE" "OPTIONS" "$NC" printf " %s%-28s%s %s\n" "$GREEN" "--debug" "$NC" "Show detailed operation logs" @@ -749,8 +748,8 @@ main() { "purge") exec "$SCRIPT_DIR/bin/purge.sh" "${args[@]:1}" ;; - "installers") - exec "$SCRIPT_DIR/bin/installers.sh" "${args[@]:1}" + "installer") + exec "$SCRIPT_DIR/bin/installer.sh" "${args[@]:1}" ;; "touchid") exec "$SCRIPT_DIR/bin/touchid.sh" "${args[@]:1}" diff --git a/tests/installers.bats b/tests/installer.bats similarity index 87% rename from tests/installers.bats rename to tests/installer.bats index 12e241e..9e09ffb 100644 --- a/tests/installers.bats +++ b/tests/installer.bats @@ -37,41 +37,13 @@ setup() { rm -rf "${HOME:?}/Documents"/* } -# Test help and arguments +# Test arguments -@test "installers.sh --help shows usage information" { - run "$PROJECT_ROOT/bin/installers.sh" --help - - [ "$status" -eq 0 ] - [[ "$output" == *"Mole Installers"* ]] - [[ "$output" == *"Usage:"* ]] - [[ "$output" == *"mo installers"* ]] -} - -@test "installers.sh --help lists options and paths" { - run "$PROJECT_ROOT/bin/installers.sh" --help - - [ "$status" -eq 0 ] - [[ "$output" == *"--debug"* ]] - [[ "$output" == *"--help"* ]] - [[ "$output" == *"mo installers"* ]] -} - -@test "installers.sh --help shows scan scope" { - run "$PROJECT_ROOT/bin/installers.sh" --help - - [ "$status" -eq 0 ] - [[ "$output" == *"Downloads"* ]] - [[ "$output" == *"Desktop"* ]] - [[ "$output" == *"Documents"* ]] -} - -@test "installers.sh rejects unknown options" { - run "$PROJECT_ROOT/bin/installers.sh" --unknown-option +@test "installer.sh rejects unknown options" { + run "$PROJECT_ROOT/bin/installer.sh" --unknown-option [ "$status" -eq 1 ] [[ "$output" == *"Unknown option"* ]] - [[ "$output" == *"--help"* ]] } # Test scan_installers_in_path function directly @@ -92,7 +64,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"Chrome.dmg"* ]] @@ -112,7 +84,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"App1.dmg"* ]] @@ -136,7 +108,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] # Default max depth is 2 @@ -159,7 +131,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"top.dmg"* ]] @@ -175,7 +147,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/NonExistent" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/NonExistent" [ "$status" -eq 0 ] [[ -z "$output" ]] @@ -195,7 +167,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" != *"document.pdf"* ]] @@ -215,7 +187,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"My App Installer.dmg"* ]] @@ -232,7 +204,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"App-v1.2.3_beta.pkg"* ]] @@ -251,7 +223,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ -z "$output" ]] @@ -268,7 +240,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"Chrome.dmg"* ]] @@ -284,7 +256,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"App1.dmg"* ]] @@ -304,7 +276,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] # Default max depth is 2 @@ -323,7 +295,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"top.dmg"* ]] @@ -335,7 +307,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/NonExistent" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/NonExistent" [ "$status" -eq 0 ] [[ -z "$output" ]] @@ -351,7 +323,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" != *"document.pdf"* ]] @@ -384,7 +356,7 @@ setup() { else echo "NOT_INSTALLER" fi - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" [ "$status" -eq 0 ] [[ "$output" == "NOT_INSTALLER" ]] @@ -407,7 +379,7 @@ setup() { else echo "NOT_INSTALLER" fi - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" [ "$status" -eq 0 ] [[ "$output" == "INSTALLER" ]] @@ -431,7 +403,7 @@ setup() { else echo "NOT_INSTALLER" fi - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" [ "$status" -eq 0 ] [[ "$output" == "NOT_INSTALLER" ]] @@ -453,7 +425,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_all_installers - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" [ "$status" -eq 0 ] [[ "$output" == *"installer.zip"* ]] @@ -474,7 +446,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_all_installers - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" [ "$status" -eq 0 ] [[ "$output" != *"data.zip"* ]] @@ -497,7 +469,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_all_installers - ' bash "$PROJECT_ROOT/bin/installers.sh" + ' bash "$PROJECT_ROOT/bin/installer.sh" # Should succeed even with missing paths [ "$status" -eq 0 ] @@ -514,7 +486,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"My App Installer.dmg"* ]] @@ -527,7 +499,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"App-v1.2.3_beta.pkg"* ]] @@ -542,7 +514,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ -z "$output" ]] @@ -562,7 +534,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" # Should succeed (return 0) and silently skip the corrupt ZIP [ "$status" -eq 0 ] @@ -592,7 +564,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" # Should succeed and find the readable.zip but skip restricted.zip [ "$status" -eq 0 ] @@ -620,7 +592,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" # Should find the valid ZIP and silently skip the corrupt one [ "$status" -eq 0 ] @@ -643,7 +615,7 @@ setup() { export MOLE_TEST_MODE=1 source "$1" scan_installers_in_path "$2" - ' bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + ' bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"real.dmg"* ]] @@ -660,7 +632,7 @@ setup() { export MOLE_TEST_MODE=1 source \"\$1\" scan_installers_in_path \"\$2\" - " bash "$PROJECT_ROOT/bin/installers.sh" "$HOME/Downloads" + " bash "$PROJECT_ROOT/bin/installer.sh" "$HOME/Downloads" [ "$status" -eq 0 ] [[ "$output" == *"real.dmg"* ]]