From 7dac5dc4e2040705394e600450bbf1b9182c505e Mon Sep 17 00:00:00 2001 From: tw93 Date: Tue, 24 Feb 2026 14:24:46 +0800 Subject: [PATCH] refactor quick launcher metadata and docs --- README.md | 2 +- scripts/setup-quick-launchers.sh | 62 ++++++++++++++++++++------------ tests/scripts.bats | 2 ++ 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 77a3d1a..d843f78 100644 --- a/README.md +++ b/README.md @@ -271,7 +271,7 @@ After running the script, complete these steps in Raycast: 3. Click **"Add Script Directory"** (or **"+"**) 4. Add path: `~/Library/Application Support/Raycast/script-commands` 5. Search in Raycast for: **"Reload Script Directories"** and run it -6. Done! Search for `mole clean`, `mole optimize`, or `mole status` to use the commands +6. Done! Search for `Mole Clean` or `clean`, `Mole Optimize`, or `Mole Status` to use the commands > **Note**: The script creates the commands, but Raycast still requires a one-time manual script directory setup. diff --git a/scripts/setup-quick-launchers.sh b/scripts/setup-quick-launchers.sh index 512d9eb..643ea75 100755 --- a/scripts/setup-quick-launchers.sh +++ b/scripts/setup-quick-launchers.sh @@ -14,6 +14,14 @@ ICON_SUCCESS="✓" ICON_WARN="!" ICON_ERR="✗" +LAUNCHER_COMMAND_SPECS=( + "clean|Mole Clean|Deep system cleanup with Mole|Run Mole clean" + "uninstall|Mole Uninstall|Uninstall applications with Mole|Uninstall apps via Mole" + "optimize|Mole Optimize|System health checks and optimization|System health and optimization" + "analyze|Mole Analyze|Disk space analysis with Mole|Disk space analysis" + "status|Mole Status|Live system status dashboard|Live system dashboard" +) + log_step() { echo -e "${BLUE}${ICON_STEP}${NC} $1"; } log_success() { echo -e "${GREEN}${ICON_SUCCESS}${NC} $1"; } log_warn() { echo -e "${YELLOW}${ICON_WARN}${NC} $1"; } @@ -239,14 +247,18 @@ create_raycast_commands() { local mo_bin="$1" local default_dir="$HOME/Library/Application Support/Raycast/script-commands" local dir="$default_dir" + local entry + local subcommand + local title + local description + local alfred_subtitle log_step "Installing Raycast commands..." mkdir -p "$dir" - write_raycast_script "$dir/mole-clean.sh" "Mole Clean" "Deep system cleanup with Mole" "$mo_bin" "clean" - write_raycast_script "$dir/mole-uninstall.sh" "Mole Uninstall" "Uninstall applications with Mole" "$mo_bin" "uninstall" - write_raycast_script "$dir/mole-optimize.sh" "Mole Optimize" "System health checks and optimization" "$mo_bin" "optimize" - write_raycast_script "$dir/mole-analyze.sh" "Mole Analyze" "Disk space analysis with Mole" "$mo_bin" "analyze" - write_raycast_script "$dir/mole-status.sh" "Mole Status" "Live system status dashboard" "$mo_bin" "status" + for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do + IFS="|" read -r subcommand title description alfred_subtitle <<< "$entry" + write_raycast_script "$dir/mole-${subcommand}.sh" "$title" "$description" "$mo_bin" "$subcommand" + done log_success "Scripts ready in: $dir" log_header "Raycast Configuration" @@ -279,22 +291,24 @@ create_alfred_workflow() { local mo_bin="$1" local prefs_dir="${ALFRED_PREFS_DIR:-$HOME/Library/Application Support/Alfred/Alfred.alfredpreferences}" local workflows_dir="$prefs_dir/workflows" + local entry + local subcommand + local title + local subtitle + local bundle + local keyword + local command if [[ ! -d "$workflows_dir" ]]; then return fi log_step "Installing Alfred workflows..." - local workflows=( - "fun.tw93.mole.clean|Mole clean|clean|Run Mole clean|\"${mo_bin}\" clean" - "fun.tw93.mole.uninstall|Mole uninstall|uninstall|Uninstall apps via Mole|\"${mo_bin}\" uninstall" - "fun.tw93.mole.optimize|Mole optimize|optimize|System health & optimization|\"${mo_bin}\" optimize" - "fun.tw93.mole.analyze|Mole analyze|analyze|Disk space analysis|\"${mo_bin}\" analyze" - "fun.tw93.mole.status|Mole status|status|Live system dashboard|\"${mo_bin}\" status" - ) - - for entry in "${workflows[@]}"; do - IFS="|" read -r bundle name keyword subtitle command <<< "$entry" + for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do + IFS="|" read -r subcommand title _ subtitle <<< "$entry" + bundle="fun.tw93.mole.${subcommand}" + keyword="${subcommand}" + command="\"${mo_bin}\" ${subcommand}" local workflow_uid="user.workflow.$(uuid | LC_ALL=C tr '[:upper:]' '[:lower:]')" local input_uid local action_uid @@ -313,7 +327,7 @@ create_alfred_workflow() { createdby Mole name - ${name} + ${title} objects @@ -326,7 +340,7 @@ create_alfred_workflow() { subtext ${subtitle} text - ${name} + ${title} withspace @@ -385,7 +399,7 @@ ${command} EOF - log_success "Workflow ready: ${name}, keyword: ${keyword}" + log_success "Workflow ready: ${title}, keyword: ${keyword}" done log_step "Open Alfred preferences → Workflows if you need to adjust keywords." @@ -406,11 +420,13 @@ main() { echo "" log_success "Done! Raycast and Alfred are ready with 5 commands:" - echo " • Mole Clean, Deep system cleanup" - echo " • Mole Uninstall, Remove applications" - echo " • Mole Optimize, System health & tuning" - echo " • Mole Analyze, Disk space explorer" - echo " • Mole Status, Live system monitor" + local entry + local subcommand + local title + for entry in "${LAUNCHER_COMMAND_SPECS[@]}"; do + IFS="|" read -r subcommand title _ _ <<< "$entry" + echo " • Raycast: ${title} | Alfred keyword: ${subcommand}" + done echo "" } diff --git a/tests/scripts.bats b/tests/scripts.bats index f607866..57a521f 100644 --- a/tests/scripts.bats +++ b/tests/scripts.bats @@ -84,6 +84,8 @@ EOF run env HOME="$HOME" TERM="dumb" PATH="$fake_bin:/usr/bin:/bin:/usr/sbin:/sbin" \ "$PROJECT_ROOT/scripts/setup-quick-launchers.sh" [ "$status" -eq 0 ] + [[ "$output" == *"Raycast: Mole Clean | Alfred keyword: clean"* ]] + [[ "$output" == *"Raycast: Mole Status | Alfred keyword: status"* ]] local raycast_dir="$HOME/Library/Application Support/Raycast/script-commands" [ -d "$raycast_dir" ]