#!/usr/bin/env bash

command:comment() {
  [ $# -ge 1 ] || error "comment requires at least an issue #"

  get-args '?owner:get-user/repo:get-repo' number

  local url="/repos/$owner/$repo/issues/$number/comments"

  local issue_report="$(git hub issue "$owner/$repo" "$number" | sed 's/^/# /')"

  editor-comment "
# Add a comment for the issue above this line.
#
$issue_report"

  if [[ ! "$body" =~ [^[:space:]] ]]; then
    abort "no comment body provided."
  fi

  api-post "$url" "$(
    json-dump-object body "$body"
  )"
}

# vim: set lisp:
