Skip to content

Commit 8cabc22

Browse files
committed
Matters of taste
- "Status" updates are more accurately success reports - Reduce color, line weight -- current choice is very noisy - No need to remind us at the end which reaction was picked -- it should still be on screen - Remove broken char in comment selection prompt
1 parent c25c040 commit 8cabc22

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

gh-react

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ NC=$'\e[0m' # No Color
1313
# Error codes
1414
declare -A err=([BADPARAM]=1 [NOPR]=2 [NOCOMMS]=3 [UNDEFTYPE]=4 [ADDFAIL]=5)
1515

16-
# Function to print colored output
17-
print_status() {
18-
printf "${BLUE}%s${NC}\n" "$@"
19-
}
20-
2116
print_header() {
2217
printf "${PURPLE}%s${NC}\n" "$@"
2318
}
@@ -27,7 +22,7 @@ print_error() {
2722
}
2823

2924
print_info() {
30-
printf "${CYAN}%s${NC}\n" "$@"
25+
printf "${NC}%s\n" "$@"
3126
}
3227

3328
print_success() {
@@ -129,7 +124,7 @@ ghPost() {
129124

130125

131126
print_header '💬 GitHub PR Reaction Tool'
132-
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
127+
print_info '———————————————————————————————————————————————————'
133128
print_info "Fetching comments for PR #$(hl "$PR_NUMBER")..."
134129

135130
print_info "Repository: $(hl "$repo")"
@@ -144,7 +139,7 @@ if [ -z "$PR_EXISTS" ]; then
144139
$(tip) Make sure you're in the correct repository and the PR number exists.
145140
EOF
146141
fi
147-
print_status "PR #$PR_NUMBER found!"
142+
print_success "PR #$PR_NUMBER found!"
148143

149144
# Use gh api to get raw comments for the issue/PR
150145
echo ""
@@ -179,21 +174,21 @@ if [ "$COMMENT_COUNT" -eq 0 ]; then
179174
EOF
180175
fi
181176

182-
print_status "Found $(hl "$COMMENT_COUNT") items to react to!"
177+
print_success "Found $(hl "$COMMENT_COUNT") items to react to!"
183178
echo ""
184179
print_info "$(hl 📋 Available content:)"
185-
echo '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
180+
echo '———————————————————————————————————————————————————'
186181

187182
# Format and display comments with numbers
188183
<"$commentsFile" render '
189184
to_entries[] | {ix: .key + 1} + .value
190185
| "[\(.ix)] \(renderType) by \(renderUser)\n\(renderBody)"
191186
'
192187

193-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
188+
echo '———————————————————————————————————————————————————'
194189
echo ""
195190
print_info "$(hl 😊 Choose what to react to:)"
196-
while read -rp "Enter number (1-$COMMENT_COUNT): " SELECTION; do
191+
while read -rp "Enter number (1-$COMMENT_COUNT): " SELECTION; do
197192
# Validate selection is a number and in range
198193
if [[ "$SELECTION" =~ ^[0-9]+$ ]] \
199194
&& [ "$SELECTION" -ge 1 ] \
@@ -223,7 +218,6 @@ select REACTION in "${!reactions[@]}"; do
223218
done
224219
unset PS3
225220

226-
227221
echo ""
228222
print_info "Sending $(hl "$REACTION") reaction to comment $(hl "$COMMENT_ID")..."
229223
declare -A endpoints=(
@@ -251,18 +245,5 @@ if ! RESPONSE=$(ghPost "${endpoints[$COMMENT_TYPE]}"/"$COMMENT_ID"/reactions \
251245
EOF
252246
fi
253247

254-
echo ""
255248
print_success "Reaction added successfully! 🎉"
256-
echo ""
257249
echo -e "$(hl 🔗 View PR:) https://github.com/$repo/pull/$PR_NUMBER"
258-
259-
# Show reaction emoji based on type
260-
case $REACTION in
261-
"+1") echo -e "${GREEN}👍 Added thumbs up!${NC}" ;;
262-
"-1") echo -e "${RED}👎 Added thumbs down!${NC}" ;;
263-
"laugh") echo -e "${YELLOW}😄 Added laugh!${NC}" ;;
264-
"heart") echo -e "${RED}❤️ Added heart!${NC}" ;;
265-
"hooray") echo -e "${PURPLE}🎉 Added hooray!${NC}" ;;
266-
"rocket") echo -e "${BLUE}🚀 Added rocket!${NC}" ;;
267-
"eyes") echo -e "${CYAN}👀 Added eyes!${NC}" ;;
268-
esac

0 commit comments

Comments
 (0)