Explorar el Código

style(tool-moyu): trunk 格式化收敛(注释对齐/花括号展开/引号风格)

b hace 1 mes
padre
commit
1c8b17d0ec
Se han modificado 1 ficheros con 10 adiciones y 7 borrados
  1. 10 7
      tool-moyu.sh

+ 10 - 7
tool-moyu.sh

@@ -26,7 +26,7 @@ LOOP_TIMES=0 # 0 = 无限
 DELAY_MS=0   # 0 = 随机 80-400
 TYPE_EFFECT=0
 SILENT=0
-COLOR_RATIO=50 # 0-100, 命中语义的行的实际上色概率(降彩色密度)
+COLOR_RATIO=50   # 0-100, 命中语义的行的实际上色概率(降彩色密度)
 EXPLICIT_COLOR=0 # 显式传 -c 时置 1, 视为显式彩色意图
 
 show_usage() {
@@ -59,7 +59,10 @@ while [ $# -gt 0 ]; do
 			exit 1
 			;;
 		esac
-		[ "$COLOR_RATIO" -gt 100 ] && { echo "color ratio must be 0-100" >&2; exit 1; }
+		[ "$COLOR_RATIO" -gt 100 ] && {
+			echo "color ratio must be 0-100" >&2
+			exit 1
+		}
 		EXPLICIT_COLOR=1
 		shift 2
 		;;
@@ -76,7 +79,7 @@ done
 # 文件模式不上色(见 run_once),此处仅决定随机内容是否套用 ANSI 主题色
 # 默认值(50)不触发强制, 仅显式传 -c 视为用户想要彩色(即使非 TTY)
 COLOR=0
-if [ -z "${NO_COLOR:-}" ] && { [ "${FORCE_COLOR:-0}" = "1" ] || [ -t 1 ] || [ "$EXPLICIT_COLOR" = "1" ]; }; then
+if [ -z "${NO_COLOR-}" ] && { [ "${FORCE_COLOR:-0}" = "1" ] || [ -t 1 ] || [ "$EXPLICIT_COLOR" = "1" ]; }; then
 	COLOR=1
 fi
 
@@ -139,7 +142,7 @@ COMMAND_OUT=(
 	"used_memory_human:1.2G · peak 1.4G · maxmemory_policy:noeviction · keys 12840"
 	"no new entries · last log 12 min ago, no warnings, no OOM"
 	"nginx: configuration file /etc/nginx/nginx.conf test is successful"
-	"{\"status\":\"ok\",\"version\":\"v1.9.2\",\"db\":\"up\",\"redis\":\"up\"}"
+	'{"status":"ok","version":"v1.9.2","db":"up","redis":"up"}'
 	"ok  git.ooo.ink/household/app/internal/pkg/notify  3.812s · race detected 0"
 	"Updating 8f3a2d1..c1e9b77 · 2 files changed, 41 insertions(+), 3 deletions(-)"
 	"internal/router/route.go +3 · internal/pkg/notify/notify.go +96 · 2 files changed"
@@ -382,10 +385,10 @@ rand_delay() {
 colorize() {
 	local line="$1" code=""
 	case "$line" in
-	'$ '*)                                code=$'\033[1;36m' ;;
-	*[Ff][Aa][Tt][Aa][Ll]*)              code=$'\033[1;31m' ;;
+	'$ '*) code=$'\033[1;36m' ;;
+	*[Ff][Aa][Tt][Aa][Ll]*) code=$'\033[1;31m' ;;
 	*ERROR* | *ERR:* | *\[err\]* | *err:*) code=$'\033[31m' ;;
-	*warn* | *WARN*)                     code=$'\033[33m' ;;
+	*warn* | *WARN*) code=$'\033[33m' ;;
 	*'✓'* | *PASS* | *'ok  '* | *'HTTP 200'* | *PONG* | *'no type errors'* | *'completed successfully'* | *'Build succeeded'*) code=$'\033[32m' ;;
 	esac
 	if [ -n "$code" ]; then