forked from zxdxjtu/claudecode-rule2hook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-test.sh
More file actions
executable file
·92 lines (77 loc) · 2.29 KB
/
quick-test.sh
File metadata and controls
executable file
·92 lines (77 loc) · 2.29 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
#!/bin/bash
echo "🧪 claudecode-rule2hook Quick Test Script"
echo "=========================="
echo ""
echo "This script will help you test the rule2hook command"
echo ""
# Color definitions
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Test function
test_rule() {
local rule="$1"
local test_name="$2"
echo -e "${YELLOW}Test:${NC} $test_name"
echo -e "${YELLOW}Rule:${NC} $rule"
echo ""
echo "Please execute in Claude Code:"
echo -e "${GREEN}/project:rule2hook \"$rule\"${NC}"
echo ""
echo "Press Enter to continue to next test..."
read
echo "---"
echo ""
}
# Start testing
echo "Preparation:"
echo "1. Ensure you are in Claude Code"
echo "2. Ensure current directory is project directory"
echo "3. Be ready to copy and paste commands"
echo ""
echo "Press Enter to start testing..."
read
# Backup existing hooks
if [ -f ~/.claude/hooks.json ]; then
cp ~/.claude/hooks.json ~/.claude/hooks.json.test_backup
echo -e "${GREEN}✓${NC} Backed up existing hooks to ~/.claude/hooks.json.test_backup"
fi
# Test 1
test_rule "Format Python files with black after editing" "Python Formatting Rule"
# Check results
echo "Check generated hooks:"
echo -e "${GREEN}cat ~/.claude/hooks.json${NC}"
echo ""
echo "Press Enter to continue..."
read
# Test 2
test_rule "Run git status when finishing a task" "Git Workflow Rule"
# Test 3
test_rule "Check for TODO comments before committing" "Code Check Rule"
# Test 4 - Read from CLAUDE.md
echo -e "${YELLOW}Test:${NC} Read rules from CLAUDE.md"
echo "Please execute in Claude Code:"
echo -e "${GREEN}/project:rule2hook${NC}"
echo ""
echo "Press Enter to continue..."
read
# Test 5 - Complex command
test_rule "Run 'npm run lint && npm run test' after editing source files" "Complex Command Rule"
# Show final results
echo "📊 Testing complete!"
echo ""
echo "View final hooks configuration:"
echo -e "${GREEN}cat ~/.claude/hooks.json | python -m json.tool${NC}"
echo ""
# Ask if restore
echo "Restore original hooks? (y/n)"
read restore
if [ "$restore" = "y" ]; then
if [ -f ~/.claude/hooks.json.test_backup ]; then
cp ~/.claude/hooks.json.test_backup ~/.claude/hooks.json
echo -e "${GREEN}✓${NC} Restored original hooks"
fi
fi
echo ""
echo "✨ Test script completed!"