mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
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:
13 files changed
+57
-147
No files matched your search
+4
-13
@@ -20,7 +20,6 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// issueArguments is the ARGUMENTS help of commands that take issue references.
|
||||
const issueArguments = `An issue can be supplied as argument in any of the following formats:
|
||||
- by number, e.g. "123" or "#123"
|
||||
- by URL, e.g. "https://gitea.com/OWNER/REPO/issues/123"
|
||||
@@ -44,8 +43,7 @@ func (a *application) issueListCommand() *cobra.Command {
|
||||
Labels and milestones must exist in the repository.`, Example: `$ tea issue list --label bug --state all
|
||||
$ tea issue list --assignee @me --json number,title
|
||||
# Issues and pull requests in a milestone, as tab-separated values
|
||||
$ tea issue list --kind all --milestone v1.0 | cut -f1,2
|
||||
$ tea issue list --search "login" --web`, Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
$ tea issue list --kind all --milestone v1.0 | cut -f1,2`, Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
var err error
|
||||
if opts.Since, opts.Before, err = updated.parse(a.deps.Now()); err != nil {
|
||||
return err
|
||||
@@ -194,13 +192,9 @@ func (a *application) issueCreateCommand() *cobra.Command {
|
||||
var useEditor, web bool
|
||||
var assignees, labelNames, attachmentPaths []string
|
||||
cmd := &cobra.Command{Use: "create", Aliases: []string{"new"}, Short: "Create an issue", Long: `Create an issue in a repository. Without flags on a terminal, a form asks for the title and
|
||||
body, then optionally for assignees, a milestone, labels and a due date. The new issue's URL
|
||||
is printed, so scripts can capture it.`, Example: `$ tea issue create
|
||||
body, then optionally for assignees, a milestone, labels and a due date.`, Example: `$ tea issue create
|
||||
$ tea issue create --title "Crash on start" --body "Steps to reproduce…" --label bug --milestone v1.0
|
||||
$ tea issue create -t "Update docs" -F notes.md -a @me
|
||||
# Start from a repository issue template, or continue in the browser
|
||||
$ tea issue create --template "Bug report"
|
||||
$ tea issue create --title "Idea" --web`, Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) (runErr error) {
|
||||
$ tea issue create --template "Bug report"`, Args: argsExact(0), RunE: func(cmd *cobra.Command, _ []string) (runErr error) {
|
||||
var draft terminal.Draft
|
||||
defer finishDraft(&draft, &runErr)
|
||||
if err := validateBodySources(cmd); err != nil {
|
||||
@@ -230,8 +224,7 @@ $ tea issue create --title "Idea" --web`, Args: argsExact(0), RunE: func(cmd *co
|
||||
return err
|
||||
}
|
||||
}
|
||||
prompt := a.canPrompt()
|
||||
if !localFlagsChanged(cmd) && prompt && a.deps.IssueForm != nil {
|
||||
if !localFlagsChanged(cmd) && a.canPrompt() && a.deps.IssueForm != nil {
|
||||
return a.createIssueInteractively(cmd)
|
||||
}
|
||||
var target target
|
||||
@@ -461,7 +454,6 @@ func milestoneFlag(cmd *cobra.Command, value string) (selected string, remove bo
|
||||
return strings.TrimSpace(value), false, nil
|
||||
}
|
||||
|
||||
// milestoneID resolves a milestone title or ID in the target repository.
|
||||
func milestoneID(cmd *cobra.Command, t target, raw string) (int64, error) {
|
||||
milestone, err := (services.Milestones{Client: t.client, Repository: t.Repo}).FindOne(cmd.Context(), raw, false)
|
||||
return milestone.ID, err
|
||||
@@ -539,7 +531,6 @@ func (f *metadataFlags) register(cmd *cobra.Command) {
|
||||
flags.StringSliceVar(&f.setAssignees, "set-assignees", nil, "Replace all assignees; an empty value clears them")
|
||||
}
|
||||
|
||||
// completeMetadataFlags completes the label and assignee flags of metadataFlags.
|
||||
func (a *application) completeMetadataFlags(cmd *cobra.Command) {
|
||||
for _, name := range []string{"add-label", "remove-label", "set-labels"} {
|
||||
_ = cmd.RegisterFlagCompletionFunc(name, a.completeLabels())
|
||||
|
||||
Reference in new issue
Block a user