hive-forge: add comment-show <id> [--json] [repo]
This commit is contained in:
parent
a9a10b631f
commit
66ec8390e1
1 changed files with 28 additions and 6 deletions
|
|
@ -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 <id> [--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 <id> [--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 <number> [body | -f <file> | - 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 <verb> [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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue