1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-11 15:18:59 +00:00

The results are more uniform

This commit is contained in:
Tw93
2025-10-11 15:02:15 +08:00
parent 8dc8d6c063
commit 3b33c5a4a8
6 changed files with 181 additions and 101 deletions

View File

@@ -22,7 +22,7 @@ readonly NC="${ESC}[0m"
# Icon definitions
readonly ICON_CONFIRM="◎" # Confirm operation
readonly ICON_ADMIN="" # Admin permission
readonly ICON_ADMIN="" # Admin permission
readonly ICON_SUCCESS="✓" # Success
readonly ICON_ERROR="✗" # Error
readonly ICON_EMPTY="○" # Empty state
@@ -116,6 +116,39 @@ icon_menu() {
echo -e "${BLUE}${ICON_MENU} ${num}. ${text}${NC}"
}
# Consistent summary blocks for command results
print_summary_block() {
local status="info"
local heading=""
if [[ $# -gt 0 ]]; then
status="$1"
shift
fi
if [[ $# -gt 0 ]]; then
heading="$1"
shift
fi
local -a details=("$@")
local divider="======================================================================"
local color="$BLUE"
local indent=" "
echo "$divider"
if [[ -n "$heading" ]]; then
echo -e "${BLUE}${heading}${NC}"
fi
for detail in "${details[@]}"; do
[[ -z "$detail" ]] && continue
echo -e "${detail}"
done
echo "$divider"
}
# System detection
detect_architecture() {
if [[ "$(uname -m)" == "arm64" ]]; then
@@ -343,7 +376,7 @@ request_sudo_access() {
# If Touch ID is supported and not forced to use password
if [[ "$force_password" != "true" ]] && check_touchid_support; then
echo -e "${BLUE}${ICON_ADMIN}${NC} ${prompt_msg} ${GRAY}(Touch ID or password)${NC}"
echo -e "${GRAY}${ICON_ADMIN}${NC} ${GRAY}${prompt_msg} (Touch ID or password)${NC}"
if sudo -v 2>/dev/null; then
return 0
else
@@ -351,8 +384,8 @@ request_sudo_access() {
fi
else
# Traditional password method
echo -e "${BLUE}${ICON_ADMIN}${NC} ${prompt_msg}"
echo -ne "${BLUE}${ICON_MENU}${NC} Password: "
echo -e "${GRAY}${ICON_ADMIN}${NC} ${GRAY}${prompt_msg}${NC}"
echo -ne "${GRAY}${ICON_MENU}${NC} Password: "
read -s password
echo ""
if [[ -n "$password" ]] && echo "$password" | sudo -S true 2>/dev/null; then