refactor(issue,pr): trim help, restating comments and single-use helpers

Cut issue, pr, label, milestone and comment examples to at most three, drop
doc comments that only restate the name, fold the comment and attachment
argument lookups into one closure each, and inline label helpers with one
caller.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 20:48:00 +02:00
1 parent 4a85bb3d40
commit 2826726557
13 files changed
+57 -147

No files matched your search

+2 -15
View File
@@ -19,7 +19,6 @@ import (
"github.com/spf13/cobra"
)
// pullArguments documents the pull request argument of pr commands in their ARGUMENTS section.
const pullArguments = `A pull request can be supplied as argument in any of the following formats:
- by number, such as "13" or "#13"
- by URL, such as "https://gitea.com/OWNER/REPO/pulls/13"
@@ -27,7 +26,6 @@ const pullArguments = `A pull request can be supplied as argument in any of the
Without an argument, the pull request of the current branch is selected.`
// pullArgumentsAnnotation adds the ARGUMENTS section to a pr command's help.
func pullArgumentsAnnotation(annotations map[string]string) map[string]string {
if annotations == nil {
annotations = map[string]string{}
@@ -43,7 +41,6 @@ var reviewStates = map[string]string{
"comment": "COMMENT", "pending": "PENDING",
}
// reviewType holds the flags that choose the type of a review.
type reviewType struct {
approve, requestChanges, comment, pending bool
// event is the hidden spelling of the type that tea 0.x and scripts use.
@@ -138,12 +135,6 @@ $ tea pr review --approve
# Request changes on #13
$ tea pr review 13 -r -b "Please hash the password"
# Comment with a body read from a file
$ tea pr review 13 -c -F notes.md
# Review interactively: pick the type, write the body, optionally annotate the diff
$ tea pr review 13
# Start a pending review with inline comments, then submit it
$ tea pr review 13 --pending --comments-file inline.json
$ tea pr review submit 13 --approve`
@@ -152,9 +143,8 @@ func (a *application) pullReviewCommand() *cobra.Command {
review := a.reviewCreateCommand("review [<number> | <url> | <branch>]", "Review a pull request or manage its reviews")
review.Long = `Submit a review on a pull request, or manage existing reviews with the commands below.
Without an argument, the pull request of the current branch is reviewed. Choose the review
type with --approve, --request-changes or --comment. On a terminal, leaving the type out
opens an interactive review that also offers to annotate the diff in your editor.`
Choose the review type with --approve, --request-changes or --comment. On a terminal, leaving
the type out opens an interactive review that also offers to annotate the diff in your editor.`
review.Example = reviewExamples
review.SuggestionsMinimumDistance = 2
create := a.reviewCreateCommand("create [<number> | <url> | <branch>]", `Submit a review (same as "tea pr review")`)
@@ -169,7 +159,6 @@ $ tea pr review create --comment -b "Looks good overall"`
return review
}
// reviewCreateCommand builds tea pr review and its explicit form tea pr review create.
func (a *application) reviewCreateCommand(use, short string) *cobra.Command {
var kind reviewType
var body, file, commentsFile, commit string
@@ -263,7 +252,6 @@ func (a *application) reportReview(cmd *cobra.Command, t target, pull services.P
return a.created(cmd, item, item.URL)
}
// readInlineComments reads the inline comments of --comments-file, a JSON array.
func readInlineComments(path string) ([]services.InlineComment, error) {
if path == "" {
return nil, nil
@@ -296,7 +284,6 @@ func readInlineComments(path string) ([]services.InlineComment, error) {
return comments, nil
}
// reviewInteractively asks for the review type, body and inline comments, then submits the review.
func (a *application) reviewInteractively(cmd *cobra.Command, args []string) error {
t, n, err := a.pullSelector(cmd, args)
if err != nil {