1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 18:30:08 +00:00

refactor(ui): unify action and list hints across commands

This commit is contained in:
tw93
2026-02-23 11:34:22 +08:00
parent 3112673ed3
commit 4c9a71315f
5 changed files with 36 additions and 35 deletions

View File

@@ -231,7 +231,8 @@ cleanup_path() {
echo -e "${GREEN}${ICON_SUCCESS}${NC} $label"
fi
else
echo -e "${GRAY}${ICON_WARNING}${NC} Skipped $label${GRAY}, grant Full Disk Access to your terminal and retry${NC}"
echo -e "${GRAY}${ICON_WARNING}${NC} Skipped $label${NC}"
echo -e "${GRAY}${ICON_REVIEW}${NC} ${GRAY}Grant Full Disk Access to your terminal, then retry${NC}"
fi
}
@@ -277,7 +278,7 @@ ask_for_security_fixes() {
done
echo ""
export MOLE_SECURITY_FIXES_SHOWN=true
echo -ne "${YELLOW}Apply now?${NC} ${GRAY}Enter confirm / Space cancel${NC}: "
echo -ne "${GRAY}${ICON_REVIEW}${NC} ${YELLOW}Apply now?${NC} ${GRAY}Enter confirm / Space cancel${NC}: "
local key
if ! key=$(read_key); then
@@ -436,7 +437,7 @@ main() {
fi
echo ""
log_error "Invalid system health data format"
echo -e "${YELLOW}Tip:${NC} Check if jq, awk, sysctl, and df commands are available"
echo -e "${GRAY}${ICON_REVIEW}${NC} Check if jq, awk, sysctl, and df commands are available"
exit 1
fi

View File

@@ -56,9 +56,9 @@ manage_purge_paths() {
for path in "${PURGE_SEARCH_PATHS[@]}"; do
local display_path="${path/#$HOME/~}"
if [[ -d "$path" ]]; then
echo -e " ${GREEN}${NC} $display_path"
echo -e " ${GREEN}${ICON_SUCCESS}${NC} $display_path"
else
echo -e " ${GRAY}${NC} $display_path${GRAY}, not found${NC}"
echo -e " ${GRAY}${ICON_EMPTY}${NC} $display_path${GRAY}, not found${NC}"
fi
done
fi

View File

@@ -25,7 +25,7 @@ format_brew_update_label() {
printf '%s' "${details[*]}"
)"
fi
printf " Homebrew%s" "$detail_str"
printf " %s Homebrew%s" "$ICON_LIST" "$detail_str"
}
brew_has_outdated() {
@@ -54,17 +54,17 @@ ask_for_updates() {
if [[ -n "${APPSTORE_UPDATE_COUNT:-}" && "${APPSTORE_UPDATE_COUNT:-0}" -gt 0 ]]; then
has_updates=true
update_list+=(" App Store, ${APPSTORE_UPDATE_COUNT} apps")
update_list+=(" ${ICON_LIST} App Store, ${APPSTORE_UPDATE_COUNT} apps")
fi
if [[ -n "${MACOS_UPDATE_AVAILABLE:-}" && "${MACOS_UPDATE_AVAILABLE}" == "true" ]]; then
has_updates=true
update_list+=(" macOS system")
update_list+=(" ${ICON_LIST} macOS system")
fi
if [[ -n "${MOLE_UPDATE_AVAILABLE:-}" && "${MOLE_UPDATE_AVAILABLE}" == "true" ]]; then
has_updates=true
update_list+=(" Mole")
update_list+=(" ${ICON_LIST} Mole")
fi
if [[ "$has_updates" == "false" ]]; then
@@ -96,7 +96,7 @@ ask_for_updates() {
fi
echo ""
echo -e "${YELLOW}💡 Run ${GREEN}brew upgrade${YELLOW} to update${NC}"
echo -e "${ICON_REVIEW} Run ${GREEN}brew upgrade${NC} to update"
return 1
}
@@ -115,7 +115,7 @@ perform_updates() {
if [[ -x "$mole_bin" ]]; then
if "$mole_bin" update 2>&1 | grep -qE "(Updated|latest version)"; then
echo -e "${GREEN}${NC} Mole updated"
echo -e "${GREEN}${ICON_SUCCESS}${NC} Mole updated"
reset_mole_cache
((updated_count++))
else

View File

@@ -562,9 +562,9 @@ batch_uninstall_applications() {
# Show success
if [[ -t 1 ]]; then
if [[ ${#app_details[@]} -gt 1 ]]; then
echo -e "${GREEN}${NC} [$current_index/${#app_details[@]}] ${app_name}"
echo -e "${GREEN}${ICON_SUCCESS}${NC} [$current_index/${#app_details[@]}] ${app_name}"
else
echo -e "${GREEN}${NC} ${app_name}"
echo -e "${GREEN}${ICON_SUCCESS}${NC} ${app_name}"
fi
fi
@@ -582,7 +582,7 @@ batch_uninstall_applications() {
echo -e "${ICON_ERROR} ${app_name} failed: $reason"
fi
if [[ -n "${suggestion:-}" ]]; then
echo -e "${GRAY} ${suggestion}${NC}"
echo -e "${GRAY} ${ICON_REVIEW} ${suggestion}${NC}"
fi
fi
@@ -662,7 +662,7 @@ batch_uninstall_applications() {
# If suggestion is same as reason, there was no suggestion part
# Also check if suggestion is empty
if [[ "$first_suggestion" != "$first_reason" && -n "$first_suggestion" ]]; then
suggestion_text="${GRAY} ${first_suggestion}${NC}"
suggestion_text="${GRAY}${ICON_REVIEW} ${first_suggestion}${NC}"
fi
case "$first_reason" in
@@ -673,7 +673,7 @@ batch_uninstall_applications() {
*) reason_summary="$first_reason" ;;
esac
fi
summary_details+=("Failed: ${RED}${failed_list}${NC} ${reason_summary}")
summary_details+=("${ICON_LIST} Failed: ${RED}${failed_list}${NC} ${reason_summary}")
if [[ -n "$suggestion_text" ]]; then
summary_details+=("$suggestion_text")
fi

38
mole
View File

@@ -242,8 +242,8 @@ update_mole() {
if is_homebrew_install; then
if [[ "$nightly_update" == "true" ]]; then
log_error "Nightly update is only available for script installations"
echo -e "${YELLOW}Tip:${NC} Homebrew installs follow stable releases."
echo -e "${YELLOW}Tip:${NC} Reinstall via script to use: ${GRAY}mo update --nightly${NC}"
echo -e "${ICON_REVIEW} Homebrew installs follow stable releases."
echo -e "${ICON_REVIEW} Reinstall via script to use: ${GRAY}mo update --nightly${NC}"
exit 1
fi
update_via_homebrew "$VERSION"
@@ -266,8 +266,8 @@ update_mole() {
if [[ -z "$latest" ]]; then
log_error "Unable to check for updates. Check network connection."
echo -e "${YELLOW}Tip:${NC} Check if you can access GitHub, https://github.com"
echo -e "${YELLOW}Tip:${NC} Try again with: ${GRAY}mo update${NC}"
echo -e "${ICON_REVIEW} Check if you can access GitHub, https://github.com"
echo -e "${ICON_REVIEW} Try again with: ${GRAY}mo update${NC}"
exit 1
fi
@@ -301,13 +301,13 @@ update_mole() {
log_error "Update failed, curl error: $curl_exit"
case $curl_exit in
6) echo -e "${YELLOW}Tip:${NC} Could not resolve host. Check DNS or network connection." ;;
7) echo -e "${YELLOW}Tip:${NC} Failed to connect. Check network or proxy settings." ;;
22) echo -e "${YELLOW}Tip:${NC} HTTP 404 Not Found. The installer may have moved." ;;
28) echo -e "${YELLOW}Tip:${NC} Connection timed out. Try again or check firewall." ;;
*) echo -e "${YELLOW}Tip:${NC} Check network connection and try again." ;;
6) echo -e "${ICON_REVIEW} Could not resolve host. Check DNS or network connection." ;;
7) echo -e "${ICON_REVIEW} Failed to connect. Check network or proxy settings." ;;
22) echo -e "${ICON_REVIEW} HTTP 404 Not Found. The installer may have moved." ;;
28) echo -e "${ICON_REVIEW} Connection timed out. Try again or check firewall." ;;
*) echo -e "${ICON_REVIEW} Check network connection and try again." ;;
esac
echo -e "${YELLOW}Tip:${NC} URL: $installer_url"
echo -e "${ICON_REVIEW} URL: $installer_url"
exit 1
}
elif command -v wget > /dev/null 2>&1; then
@@ -315,15 +315,15 @@ update_mole() {
if [[ -t 1 ]]; then stop_inline_spinner; fi
rm -f "$tmp_installer"
log_error "Update failed, wget error"
echo -e "${YELLOW}Tip:${NC} Check network connection and try again."
echo -e "${YELLOW}Tip:${NC} URL: $installer_url"
echo -e "${ICON_REVIEW} Check network connection and try again."
echo -e "${ICON_REVIEW} URL: $installer_url"
exit 1
}
else
if [[ -t 1 ]]; then stop_inline_spinner; fi
rm -f "$tmp_installer"
log_error "curl or wget required"
echo -e "${YELLOW}Tip:${NC} Install curl with: ${GRAY}brew install curl${NC}"
echo -e "${ICON_REVIEW} Install curl with: ${GRAY}brew install curl${NC}"
exit 1
fi
@@ -520,13 +520,13 @@ remove_mole() {
echo -e "${YELLOW}Remove Mole${NC}, will delete the following:"
if [[ "$is_homebrew" == "true" ]]; then
echo " * Mole via Homebrew"
echo " ${ICON_LIST} Mole via Homebrew"
fi
for install in ${manual_installs[@]+"${manual_installs[@]}"} ${alias_installs[@]+"${alias_installs[@]}"}; do
echo " * $install"
echo " ${ICON_LIST} $install"
done
echo " * ~/.config/mole"
echo " * ~/.cache/mole"
echo " ${ICON_LIST} ~/.config/mole"
echo " ${ICON_LIST} ~/.cache/mole"
echo -ne "${PURPLE}${ICON_ARROW}${NC} Press ${GREEN}Enter${NC} to confirm, ${GRAY}ESC${NC} to cancel: "
IFS= read -r -s -n1 key || key=""
@@ -547,7 +547,7 @@ remove_mole() {
if [[ "$is_homebrew" == "true" ]]; then
if [[ -z "$brew_cmd" ]]; then
log_error "Homebrew command not found. Please ensure Homebrew is installed and in your PATH."
log_warning "You may need to manually run: brew uninstall --force mole"
log_warning "Manual step: brew uninstall --force mole"
exit 1
fi
@@ -557,7 +557,7 @@ remove_mole() {
has_error=true
log_error "Homebrew uninstallation failed:"
printf "%s\n" "$brew_uninstall_output" | sed "s/^/${RED} | ${NC}/" >&2
log_warning "Please manually run: ${YELLOW}brew uninstall --force mole${NC}"
log_warning "Manual step: ${YELLOW}brew uninstall --force mole${NC}"
echo "" # Add a blank line for readability
else
log_success "Mole uninstalled via Homebrew."