From 66ec8390e1b83a519c6d006f628be7984fac8cca Mon Sep 17 00:00:00 2001 From: damocles Date: Fri, 22 May 2026 20:19:37 +0200 Subject: [PATCH] hive-forge: add comment-show [--json] [repo] --- nix/packages/hive-forge-tools.nix | 34 +++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/nix/packages/hive-forge-tools.nix b/nix/packages/hive-forge-tools.nix index 421844a..46ed2d0 100644 --- a/nix/packages/hive-forge-tools.nix +++ b/nix/packages/hive-forge-tools.nix @@ -108,6 +108,27 @@ pkgs.writeShellApplication { | jq '{number,title,state,merged,user:.user.login,head_sha:.head.sha,head_branch:.head.label,base_branch:.base.label}' } + cmd_comment_show() { + # comment-show [--json] [repo] + # Print the body (or full JSON with --json) of a single comment by its id. + if [ $# -lt 1 ]; then echo "usage: hive-forge comment-show [--json] [repo]" >&2; exit 1; fi + local _id="$1"; shift + local _json=false _repo="$HIVE_FORGE_REPO" + while [ $# -gt 0 ]; do + case "$1" in + --json) _json=true; shift ;; + *) _repo="$1"; shift ;; + esac + done + local _resp + _resp=$(forge_get "$FORGE_API/repos/$_repo/issues/comments/$_id") + if [ "$_json" = true ]; then + printf '%s\n' "$_resp" | jq '{id,user:.user.login,created_at,updated_at,body,url:.html_url}' + else + printf '%s\n' "$_resp" | jq -r '.body' + fi + } + cmd_comment() { # comment [body | -f | - for stdin] # Post a comment on an issue or PR. @@ -423,9 +444,9 @@ pkgs.writeShellApplication { VERB="''${1:-}" if [ -z "$VERB" ]; then echo "usage: hive-forge [args...]" >&2 - echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, assign, close," >&2 - echo " labels, milestone, pr-reviews, branches, tree-sha, diff, subscription," >&2 - echo " attach-issue, attach-comment" >&2 + echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, comment-show," >&2 + echo " assign, close, labels, milestone, pr-reviews, branches, tree-sha, diff," >&2 + echo " subscription, attach-issue, attach-comment" >&2 exit 1 fi shift @@ -438,6 +459,7 @@ pkgs.writeShellApplication { pr) cmd_pr "$@" ;; pr-create) cmd_pr_create "$@" ;; comment) cmd_comment "$@" ;; + comment-show) cmd_comment_show "$@" ;; assign) cmd_assign "$@" ;; close) cmd_close "$@" ;; labels) cmd_labels "$@" ;; @@ -451,9 +473,9 @@ pkgs.writeShellApplication { attach-comment) cmd_attach_comment "$@" ;; *) echo "hive-forge: unknown verb '$VERB'" >&2 - echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, assign, close," >&2 - echo " labels, milestone, pr-reviews, branches, tree-sha, diff, subscription," >&2 - echo " attach-issue, attach-comment" >&2 + echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, comment-show," >&2 + echo " assign, close, labels, milestone, pr-reviews, branches, tree-sha, diff," >&2 + echo " subscription, attach-issue, attach-comment" >&2 exit 1 ;; esac