@@ -50,8 +50,32 @@ hl2() {
5050tip () {
5151 printf " 💡 ${YELLOW} %s${NC} " " ${1:- Tip} :"
5252}
53- user () {
54- printf " ${CYAN} @%s${NC} " " $1 "
53+
54+ # Pretty-printer for response data
55+ render () {
56+ jq \
57+ --arg nc " $NC " \
58+ --argjson color \
59+ " $( jq --null-input ' $ARGS.named' \
60+ --arg PR_BODY " $PURPLE " \
61+ --arg ISSUE " $GREEN " \
62+ --arg REVIEW " $YELLOW " \
63+ --arg REVIEW_SUMMARY " $BLUE " \
64+ --arg USER " $CYAN "
65+ ) " \
66+ -r '
67+ def renderType: .type
68+ | "\($color[.])" + {
69+ PR_BODY: "📄 PR Description",
70+ ISSUE: "💬 Comment",
71+ REVIEW: "🔍 Code Review",
72+ REVIEW_SUMMARY: "📝 Review Summary",
73+ }[.] + $nc;
74+ def renderUser: .author
75+ | "\($color["USER"])\(.)\($nc)";
76+ def renderBody: .body | gsub("\\s"; " ")
77+ | "\t└─\(.[:80])\(if length > 80 then "..." else "" end)";
78+ ' " $1 "
5579}
5680
5781usage () {
@@ -161,28 +185,7 @@ print_info "$(hl 📋 Available content:)"
161185echo ' ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'
162186
163187# Format and display comments with numbers
164- < " $commentsFile " jq \
165- --arg nc " $NC " \
166- --argjson color \
167- " $( jq --null-input ' $ARGS.named' \
168- --arg PR_BODY " $PURPLE " \
169- --arg ISSUE " $GREEN " \
170- --arg REVIEW " $YELLOW " \
171- --arg REVIEW_SUMMARY " $BLUE " \
172- --arg USER " $CYAN "
173- ) " \
174- -r '
175- def renderType: .type
176- | "\($color[.])" + {
177- PR_BODY: "📄 PR Description",
178- ISSUE: "💬 Comment",
179- REVIEW: "🔍 Code Review",
180- REVIEW_SUMMARY: "📝 Review Summary",
181- }[.] + $nc;
182- def renderUser: .author
183- | "\($color["USER"])\(.)\($nc)";
184- def renderBody: .body | gsub("\\s"; " ")
185- | "\t└─\(.[:80])\(if length > 80 then "..." else "" end)";
188+ < " $commentsFile " render '
186189 to_entries[] | {ix: .key + 1} + .value
187190 | "[\(.ix)] \(renderType) by \(renderUser)\n\(renderBody)"
188191 '
@@ -205,7 +208,8 @@ COMMENT_ID=$(jq ".[$SELECTION-1].id" "$commentsFile")
205208SELECTED_AUTHOR=$( jq -r " .[$SELECTION -1].author" " $commentsFile " )
206209
207210echo " "
208- print_info " Selected: $( hl " $COMMENT_TYPE " ) by $( user " $SELECTED_AUTHOR " ) "
211+ < " $commentsFile " render " .[$SELECTION -1]" '
212+ | "Selected \(renderType) by \(renderUser)"'
209213
210214declare -A reactions=(
211215 [👍]=+1 [👎]=-1 [😄]=laugh [❤️]=heart [🎉]=hooray [🚀]=rocket [👀]=eyes
0 commit comments