-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdev
More file actions
executable file
·135 lines (124 loc) · 3.55 KB
/
dev
File metadata and controls
executable file
·135 lines (124 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
set -euo pipefail
# dev — idpishield developer toolkit
# Usage: dev [command] Run a command directly
# dev Show help
cd "$(dirname "$0")"
BOLD=$'\033[1m'
ACCENT=$'\033[38;2;251;191;36m'
MUTED=$'\033[38;2;90;100;128m'
SUCCESS=$'\033[38;2;0;229;204m'
ERROR=$'\033[38;2;230;57;70m'
NC=$'\033[0m'
# ── Commands ─────────────────────────────────────────────────────────
COMMANDS=(
"build:📦:Build binary"
"check:✅:Run all checks (fmt + vet + build + lint + test)"
"test:🧪:Run tests"
"test verbose:🧪:Run tests (verbose)"
"test race:🧪:Run tests with race detector"
"doctor:🩺:Setup dev environment"
"fmt:✨:Format code"
"vet:🔬:Run go vet"
"lint:🔍:Run golangci-lint"
"coverage:📊:Run tests with coverage"
"benchmark:🏋:Run benchmarks"
"benchmark optimize:🏋:Run benchmark optimization loop setup"
)
show_help() {
echo ""
echo " ${BOLD}${ACCENT}idpishield${NC} ${MUTED}— development tool${NC}"
echo ""
for entry in "${COMMANDS[@]}"; do
IFS=':' read -r cmd icon desc <<< "$entry"
printf " ${ACCENT}%-22s${NC} %s %s\n" "./dev $cmd" "$icon" "$desc"
done
echo ""
}
run_command() {
local target="$1"
local subcommand="${2:-}"
echo ""
case "$target" in
"build")
echo " ${ACCENT}${BOLD}📦 Building idpishield${NC}"
echo ""
go build -o idpishield ./cmd/idpishield
echo " ${SUCCESS}✓${NC} Built: ./idpishield"
;;
"check")
exec bash scripts/check.sh
;;
"test")
case "$subcommand" in
verbose)
echo " ${ACCENT}${BOLD}🧪 Running tests (verbose)${NC}"
echo ""
go test ./... -count=1 -v
;;
race)
echo " ${ACCENT}${BOLD}🧪 Running tests with race detector${NC}"
echo ""
go test ./... -count=1 -race
;;
*)
exec bash scripts/test.sh
;;
esac
;;
"doctor")
exec bash scripts/doctor.sh
;;
"fmt")
echo " ${ACCENT}${BOLD}✨ Formatting code${NC}"
echo ""
gofmt -w .
echo " ${SUCCESS}✓${NC} Formatted"
;;
"vet")
echo " ${ACCENT}${BOLD}🔬 Running go vet${NC}"
echo ""
go vet ./...
echo " ${SUCCESS}✓${NC} Vet clean"
;;
"lint")
echo " ${ACCENT}${BOLD}🔍 Running linter${NC}"
echo ""
golangci-lint run
echo " ${SUCCESS}✓${NC} Lint clean"
;;
"coverage")
echo " ${ACCENT}${BOLD}📊 Running tests with coverage${NC}"
echo ""
go test ./... -count=1 -coverprofile=coverage.out -covermode=atomic
go tool cover -func=coverage.out | tail -1
echo ""
echo " ${MUTED}HTML report: go tool cover -html=coverage.out${NC}"
;;
"benchmark")
case "$subcommand" in
optimize)
exec bash tests/benchmark/scripts/run-optimization.sh
;;
*)
exec bash tests/benchmark/scripts/run-benchmark.sh
;;
esac
;;
*)
echo " ${ERROR}Unknown command: $target${NC}"
show_help
exit 1
;;
esac
}
# ── Main ─────────────────────────────────────────────────────────────
if [ $# -gt 0 ]; then
case "$1" in
-h|--help|help) show_help; exit 0 ;;
*) run_command "$1" "${2:-}" ;;
esac
exit 0
fi
# No args → show help
show_help