1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-14 19:57:28 +00:00

refactor: remove Christmas seasonal feature

This commit is contained in:
Tw93
2026-01-02 19:26:22 +08:00
parent 115e2d3ef1
commit 6c8c87bef6
3 changed files with 17 additions and 128 deletions

View File

@@ -5,7 +5,6 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
) )
@@ -17,7 +16,7 @@ var (
dangerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5F5F")).Bold(true) dangerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5F5F")).Bold(true)
okStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#A5D6A7")) okStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#A5D6A7"))
lineStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#404040")) lineStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#404040"))
hatStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF4D4D"))
primaryStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9")) primaryStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9"))
) )
@@ -33,14 +32,6 @@ const (
iconProcs = "❊" iconProcs = "❊"
) )
// isChristmasSeason reports Dec 10-31.
func isChristmasSeason() bool {
now := time.Now()
month := now.Month()
day := now.Day()
return month == time.December && day >= 10 && day <= 31
}
// Mole body frames. // Mole body frames.
var moleBody = [][]string{ var moleBody = [][]string{
{ {
@@ -69,55 +60,10 @@ var moleBody = [][]string{
}, },
} }
// Mole body frames with Christmas hat.
var moleBodyWithHat = [][]string{
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)-m-m)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)mm__)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ · · \`,
` /___ =-= /`,
` \___)-m__m)`,
},
{
` *`,
` /o\`,
` {/\_/\}`,
` ___/ o o \`,
` /___ =-= /`,
` \____)-mm-)`,
},
}
// getMoleFrame renders the animated mole. // getMoleFrame renders the animated mole.
func getMoleFrame(animFrame int, termWidth int) string { func getMoleFrame(animFrame int, termWidth int) string {
var body []string bodyIdx := animFrame % len(moleBody)
var bodyIdx int body := moleBody[bodyIdx]
isChristmas := isChristmasSeason()
if isChristmas {
bodyIdx = animFrame % len(moleBodyWithHat)
body = moleBodyWithHat[bodyIdx]
} else {
bodyIdx = animFrame % len(moleBody)
body = moleBody[bodyIdx]
}
moleWidth := 15 moleWidth := 15
maxPos := termWidth - moleWidth maxPos := termWidth - moleWidth
@@ -137,19 +83,9 @@ func getMoleFrame(animFrame int, termWidth int) string {
padding := strings.Repeat(" ", pos) padding := strings.Repeat(" ", pos)
var lines []string var lines []string
if isChristmas {
for i, line := range body {
if i < 3 {
lines = append(lines, padding+hatStyle.Render(line))
} else {
lines = append(lines, padding+line)
}
}
} else {
for _, line := range body { for _, line := range body {
lines = append(lines, padding+line) lines = append(lines, padding+line)
} }
}
return strings.Join(lines, "\n") return strings.Join(lines, "\n")
} }

View File

@@ -55,21 +55,6 @@ readonly MOLE_TM_BACKUP_SAFE_HOURS=48 # TM backup safety window (hours)
readonly MOLE_MAX_DS_STORE_FILES=500 # Max .DS_Store files to clean per scan readonly MOLE_MAX_DS_STORE_FILES=500 # Max .DS_Store files to clean per scan
readonly MOLE_MAX_ORPHAN_ITERATIONS=100 # Max iterations for orphaned app data scan readonly MOLE_MAX_ORPHAN_ITERATIONS=100 # Max iterations for orphaned app data scan
# ============================================================================
# Seasonal Functions
# ============================================================================
is_christmas_season() {
local month day
month=$(date +%-m)
day=$(date +%-d)
# December 10 to December 31
if [[ $month -eq 12 && $day -ge 10 && $day -le 31 ]]; then
return 0
fi
return 1
}
# ============================================================================ # ============================================================================
# Whitelist Configuration # Whitelist Configuration
# ============================================================================ # ============================================================================

34
mole
View File

@@ -129,21 +129,6 @@ animate_mole_intro() {
local -a mole_lines=() local -a mole_lines=()
if is_christmas_season; then
while IFS= read -r line; do
mole_lines+=("$line")
done << 'EOF'
*
/o\
{/\_/\}
____/ o o \
/~____ =o= /
(______)__m_m)
/ \
__/ /\ \__
/__/ \__\_
EOF
else
while IFS= read -r line; do while IFS= read -r line; do
mole_lines+=("$line") mole_lines+=("$line")
done << 'EOF' done << 'EOF'
@@ -155,28 +140,12 @@ EOF
__/ /\ \__ __/ /\ \__
/__/ \__\_ /__/ \__\_
EOF EOF
fi
local idx local idx
local hat_color="${RED}" local body_cutoff=4
local body_cutoff
local body_color="${PURPLE}" local body_color="${PURPLE}"
local ground_color="${GREEN}" local ground_color="${GREEN}"
if is_christmas_season; then
body_cutoff=6
for idx in "${!mole_lines[@]}"; do
if ((idx < 3)); then
printf "%s\n" "${hat_color}${mole_lines[$idx]}${NC}"
elif ((idx < body_cutoff)); then
printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}"
else
printf "%s\n" "${ground_color}${mole_lines[$idx]}${NC}"
fi
sleep 0.1
done
else
body_cutoff=4
for idx in "${!mole_lines[@]}"; do for idx in "${!mole_lines[@]}"; do
if ((idx < body_cutoff)); then if ((idx < body_cutoff)); then
printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}" printf "%s\n" "${body_color}${mole_lines[$idx]}${NC}"
@@ -185,7 +154,6 @@ EOF
fi fi
sleep 0.1 sleep 0.1
done done
fi
printf '\n' printf '\n'
sleep 0.5 sleep 0.5