mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 11:31:46 +00:00
refactor: remove Christmas seasonal feature
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
@@ -17,7 +16,7 @@ var (
|
||||
dangerStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF5F5F")).Bold(true)
|
||||
okStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#A5D6A7"))
|
||||
lineStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#404040"))
|
||||
hatStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#FF4D4D"))
|
||||
|
||||
primaryStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("#BD93F9"))
|
||||
)
|
||||
|
||||
@@ -33,14 +32,6 @@ const (
|
||||
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.
|
||||
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.
|
||||
func getMoleFrame(animFrame int, termWidth int) string {
|
||||
var body []string
|
||||
var bodyIdx int
|
||||
isChristmas := isChristmasSeason()
|
||||
|
||||
if isChristmas {
|
||||
bodyIdx = animFrame % len(moleBodyWithHat)
|
||||
body = moleBodyWithHat[bodyIdx]
|
||||
} else {
|
||||
bodyIdx = animFrame % len(moleBody)
|
||||
body = moleBody[bodyIdx]
|
||||
}
|
||||
bodyIdx := animFrame % len(moleBody)
|
||||
body := moleBody[bodyIdx]
|
||||
|
||||
moleWidth := 15
|
||||
maxPos := termWidth - moleWidth
|
||||
@@ -137,18 +83,8 @@ func getMoleFrame(animFrame int, termWidth int) string {
|
||||
padding := strings.Repeat(" ", pos)
|
||||
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 {
|
||||
lines = append(lines, padding+line)
|
||||
}
|
||||
for _, line := range body {
|
||||
lines = append(lines, padding+line)
|
||||
}
|
||||
|
||||
return strings.Join(lines, "\n")
|
||||
|
||||
@@ -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_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
|
||||
# ============================================================================
|
||||
|
||||
56
mole
56
mole
@@ -129,24 +129,9 @@ animate_mole_intro() {
|
||||
|
||||
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
|
||||
mole_lines+=("$line")
|
||||
done << 'EOF'
|
||||
while IFS= read -r line; do
|
||||
mole_lines+=("$line")
|
||||
done << 'EOF'
|
||||
/\_/\
|
||||
____/ o o \
|
||||
/~____ =o= /
|
||||
@@ -155,37 +140,20 @@ EOF
|
||||
__/ /\ \__
|
||||
/__/ \__\_
|
||||
EOF
|
||||
fi
|
||||
|
||||
local idx
|
||||
local hat_color="${RED}"
|
||||
local body_cutoff
|
||||
local body_cutoff=4
|
||||
local body_color="${PURPLE}"
|
||||
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
|
||||
if ((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
|
||||
fi
|
||||
for idx in "${!mole_lines[@]}"; do
|
||||
if ((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
|
||||
|
||||
printf '\n'
|
||||
sleep 0.5
|
||||
|
||||
Reference in New Issue
Block a user