1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 12:41:46 +00:00

chore: auto format code

This commit is contained in:
Tw93
2025-12-27 02:19:22 +00:00
parent 162180d9b5
commit f2160b7cab
3 changed files with 30 additions and 30 deletions

View File

@@ -95,7 +95,7 @@ scan_installed_apps() {
debug_log "Using cached app list (age: ${age}s)"
# Verify cache file is readable and not empty
if [[ -r "$cache_file" ]] && [[ -s "$cache_file" ]]; then
if cat "$cache_file" > "$installed_bundles" 2>/dev/null; then
if cat "$cache_file" > "$installed_bundles" 2> /dev/null; then
return 0
else
debug_log "Warning: Failed to read cache, rebuilding"
@@ -180,9 +180,9 @@ scan_installed_apps() {
# Cache the results
ensure_user_dir "$(dirname "$cache_file")"
cp "$installed_bundles" "$cache_file" 2>/dev/null || true
cp "$installed_bundles" "$cache_file" 2> /dev/null || true
local app_count=$(wc -l < "$installed_bundles" 2>/dev/null | tr -d ' ')
local app_count=$(wc -l < "$installed_bundles" 2> /dev/null | tr -d ' ')
debug_log "Scanned $app_count unique applications"
}

View File

@@ -596,12 +596,12 @@ safe_clear_lines() {
# Use centralized ANSI support check (defined below)
# Note: This forward reference works because functions are parsed before execution
is_ansi_supported 2>/dev/null || return 1
is_ansi_supported 2> /dev/null || return 1
# Clear lines one by one (more reliable than multi-line sequences)
local i
for ((i=0; i<lines; i++)); do
printf "\033[1A\r\033[K" > "$tty_device" 2>/dev/null || return 1
for ((i = 0; i < lines; i++)); do
printf "\033[1A\r\033[K" > "$tty_device" 2> /dev/null || return 1
done
return 0
@@ -613,9 +613,9 @@ safe_clear_line() {
local tty_device="${1:-/dev/tty}"
# Use centralized ANSI support check
is_ansi_supported 2>/dev/null || return 1
is_ansi_supported 2> /dev/null || return 1
printf "\r\033[K" > "$tty_device" 2>/dev/null || return 1
printf "\r\033[K" > "$tty_device" 2> /dev/null || return 1
return 0
}
@@ -663,7 +663,7 @@ push_spinner_state() {
local current_state=""
# Save current spinner PID if running
if [[ -n "${MOLE_SPINNER_PID:-}" ]] && kill -0 "$MOLE_SPINNER_PID" 2>/dev/null; then
if [[ -n "${MOLE_SPINNER_PID:-}" ]] && kill -0 "$MOLE_SPINNER_PID" 2> /dev/null; then
current_state="running:$MOLE_SPINNER_PID"
else
current_state="stopped"
@@ -693,7 +693,7 @@ pop_spinner_state() {
# Instead of unset, rebuild array without last element
local -a new_stack=()
local i
for ((i=0; i<last_idx; i++)); do
for ((i = 0; i < last_idx; i++)); do
new_stack+=("${MOLE_SPINNER_STACK[$i]}")
done
MOLE_SPINNER_STACK=("${new_stack[@]}")
@@ -719,7 +719,7 @@ safe_start_spinner() {
push_spinner_state
# Stop any existing spinner
stop_section_spinner 2>/dev/null || true
stop_section_spinner 2> /dev/null || true
# Start new spinner
start_section_spinner "$message"
@@ -729,7 +729,7 @@ safe_start_spinner() {
# Usage: safe_stop_spinner
safe_stop_spinner() {
# Stop current spinner
stop_section_spinner 2>/dev/null || true
stop_section_spinner 2> /dev/null || true
# Pop previous state
pop_spinner_state || true
@@ -751,17 +751,17 @@ is_ansi_supported() {
# Check for known ANSI-compatible terminals
case "$TERM" in
xterm*|vt100|vt220|screen*|tmux*|ansi|linux|rxvt*|konsole*)
xterm* | vt100 | vt220 | screen* | tmux* | ansi | linux | rxvt* | konsole*)
return 0
;;
dumb|unknown)
dumb | unknown)
return 1
;;
*)
# Check terminfo database if available
if command -v tput >/dev/null 2>&1; then
if command -v tput > /dev/null 2>&1; then
# Test if terminal supports colors (good proxy for ANSI support)
local colors=$(tput colors 2>/dev/null || echo "0")
local colors=$(tput colors 2> /dev/null || echo "0")
[[ "$colors" -ge 8 ]] && return 0
fi
return 1
@@ -777,10 +777,10 @@ get_terminal_info() {
if is_ansi_supported; then
info+=" (ANSI supported)"
if command -v tput >/dev/null 2>&1; then
local cols=$(tput cols 2>/dev/null || echo "?")
local lines=$(tput lines 2>/dev/null || echo "?")
local colors=$(tput colors 2>/dev/null || echo "?")
if command -v tput > /dev/null 2>&1; then
local cols=$(tput cols 2> /dev/null || echo "?")
local lines=$(tput lines 2> /dev/null || echo "?")
local colors=$(tput colors 2> /dev/null || echo "?")
info+=" ${cols}x${lines}, ${colors} colors"
fi
else
@@ -815,8 +815,8 @@ validate_terminal_environment() {
esac
# Check terminal size if available
if command -v tput >/dev/null 2>&1; then
local cols=$(tput cols 2>/dev/null || echo "80")
if command -v tput > /dev/null 2>&1; then
local cols=$(tput cols 2> /dev/null || echo "80")
if [[ "$cols" -lt 60 ]]; then
log_warning "Terminal width ($cols cols) is narrow - output may wrap"
((warnings++))

8
mole
View File

@@ -64,7 +64,7 @@ is_homebrew_install() {
# Symlink looks good, but verify brew actually manages it
if command -v brew > /dev/null 2>&1; then
# Use fast brew list check
brew list --formula 2>/dev/null | grep -q "^mole$" && return 0
brew list --formula 2> /dev/null | grep -q "^mole$" && return 0
else
# brew not available - cannot update/remove via Homebrew
return 1
@@ -74,12 +74,12 @@ is_homebrew_install() {
# Fallback: check common Homebrew paths and verify with Cellar
if [[ -f "$mole_path" ]]; then
case "$mole_path" in
/opt/homebrew/bin/mole|/usr/local/bin/mole)
/opt/homebrew/bin/mole | /usr/local/bin/mole)
# Verify Cellar directory exists
if [[ -d /opt/homebrew/Cellar/mole ]] || [[ -d /usr/local/Cellar/mole ]]; then
# Double-check with brew if available
if command -v brew > /dev/null 2>&1; then
brew list --formula 2>/dev/null | grep -q "^mole$" && return 0
brew list --formula 2> /dev/null | grep -q "^mole$" && return 0
else
return 0 # Cellar exists, probably Homebrew install
fi
@@ -93,7 +93,7 @@ is_homebrew_install() {
local brew_prefix
brew_prefix=$(brew --prefix 2> /dev/null)
if [[ -n "$brew_prefix" && "$mole_path" == "$brew_prefix/bin/mole" && -d "$brew_prefix/Cellar/mole" ]]; then
brew list --formula 2>/dev/null | grep -q "^mole$" && return 0
brew list --formula 2> /dev/null | grep -q "^mole$" && return 0
fi
fi