From 5e7c702e07598dbe8a25bc4941b25760f8b2cefc Mon Sep 17 00:00:00 2001 From: Norwin Date: Wed, 14 Sep 2022 02:14:02 +0800 Subject: [PATCH] Clarify command descriptions when no arguments are taken (#496) This changes the command help string from eg ``` NAME: tea label create - Create a label USAGE: tea label [command options] [arguments...] ``` to ``` NAME: tea label create - Create a label USAGE: tea label [command options] ``` Hopefully improving usability. --- edit: this also changes `tea release create` to take the `--tag` flag value optionally via the first argument, as this seems to be a clear UX improvement. fixes #483 Co-authored-by: Norwin Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitea/tea/pulls/496 Reviewed-by: techknowlogick Reviewed-by: 6543 <6543@obermui.de> Reviewed-by: delvh Co-authored-by: Norwin Co-committed-by: Norwin --- cmd/issues/create.go | 1 + cmd/issues/list.go | 1 + cmd/labels.go | 1 + cmd/labels/create.go | 1 + cmd/labels/delete.go | 1 + cmd/labels/list.go | 1 + cmd/labels/update.go | 1 + cmd/login/add.go | 1 + cmd/login/edit.go | 1 + cmd/login/list.go | 1 + cmd/milestones/create.go | 1 + cmd/milestones/list.go | 1 + cmd/notifications/list.go | 1 + cmd/organizations/list.go | 1 + cmd/pulls/list.go | 1 + cmd/releases.go | 1 + cmd/releases/create.go | 13 +++++++++++-- cmd/releases/list.go | 1 + cmd/repos/create.go | 1 + cmd/repos/fork.go | 1 + cmd/whoami.go | 1 + 21 files changed, 31 insertions(+), 2 deletions(-) diff --git a/cmd/issues/create.go b/cmd/issues/create.go index 73b162b..90d3964 100644 --- a/cmd/issues/create.go +++ b/cmd/issues/create.go @@ -19,6 +19,7 @@ var CmdIssuesCreate = cli.Command{ Aliases: []string{"c"}, Usage: "Create an issue on repository", Description: `Create an issue on repository`, + ArgsUsage: " ", // command does not accept arguments Action: runIssuesCreate, Flags: flags.IssuePREditFlags, } diff --git a/cmd/issues/list.go b/cmd/issues/list.go index e5999fb..b67680d 100644 --- a/cmd/issues/list.go +++ b/cmd/issues/list.go @@ -27,6 +27,7 @@ var CmdIssuesList = cli.Command{ Aliases: []string{"ls"}, Usage: "List issues of the repository", Description: `List issues of the repository`, + ArgsUsage: " ", // command does not accept arguments Action: RunIssuesList, Flags: append([]cli.Flag{issueFieldsFlag}, flags.IssueListingFlags...), } diff --git a/cmd/labels.go b/cmd/labels.go index 07098c1..79cbbd2 100644 --- a/cmd/labels.go +++ b/cmd/labels.go @@ -18,6 +18,7 @@ var CmdLabels = cli.Command{ Category: catEntities, Usage: "Manage issue labels", Description: `Manage issue labels`, + ArgsUsage: " ", // command does not accept arguments Action: runLabels, Subcommands: []*cli.Command{ &labels.CmdLabelsList, diff --git a/cmd/labels/create.go b/cmd/labels/create.go index ff850ea..b95d696 100644 --- a/cmd/labels/create.go +++ b/cmd/labels/create.go @@ -23,6 +23,7 @@ var CmdLabelCreate = cli.Command{ Aliases: []string{"c"}, Usage: "Create a label", Description: `Create a label`, + ArgsUsage: " ", // command does not accept arguments Action: runLabelCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ diff --git a/cmd/labels/delete.go b/cmd/labels/delete.go index 7a47b54..3e3b53e 100644 --- a/cmd/labels/delete.go +++ b/cmd/labels/delete.go @@ -17,6 +17,7 @@ var CmdLabelDelete = cli.Command{ Aliases: []string{"rm"}, Usage: "Delete a label", Description: `Delete a label`, + ArgsUsage: " ", // command does not accept arguments Action: runLabelDelete, Flags: append([]cli.Flag{ &cli.IntFlag{ diff --git a/cmd/labels/list.go b/cmd/labels/list.go index 6d2790f..a16139f 100644 --- a/cmd/labels/list.go +++ b/cmd/labels/list.go @@ -20,6 +20,7 @@ var CmdLabelsList = cli.Command{ Aliases: []string{"ls"}, Usage: "List labels", Description: "List labels", + ArgsUsage: " ", // command does not accept arguments Action: RunLabelsList, Flags: append([]cli.Flag{ &cli.BoolFlag{ diff --git a/cmd/labels/update.go b/cmd/labels/update.go index 6b2106f..a9984cf 100644 --- a/cmd/labels/update.go +++ b/cmd/labels/update.go @@ -17,6 +17,7 @@ var CmdLabelUpdate = cli.Command{ Name: "update", Usage: "Update a label", Description: `Update a label`, + ArgsUsage: " ", // command does not accept arguments Action: runLabelUpdate, Flags: append([]cli.Flag{ &cli.IntFlag{ diff --git a/cmd/login/add.go b/cmd/login/add.go index 56799c3..a794b83 100644 --- a/cmd/login/add.go +++ b/cmd/login/add.go @@ -16,6 +16,7 @@ var CmdLoginAdd = cli.Command{ Name: "add", Usage: "Add a Gitea login", Description: `Add a Gitea login, without args it will create one interactively`, + ArgsUsage: " ", // command does not accept arguments Flags: []cli.Flag{ &cli.StringFlag{ Name: "name", diff --git a/cmd/login/edit.go b/cmd/login/edit.go index cc56f5d..c28b031 100644 --- a/cmd/login/edit.go +++ b/cmd/login/edit.go @@ -18,6 +18,7 @@ var CmdLoginEdit = cli.Command{ Aliases: []string{"e"}, Usage: "Edit Gitea logins", Description: `Edit Gitea logins`, + ArgsUsage: " ", // command does not accept arguments Action: runLoginEdit, Flags: []cli.Flag{&flags.OutputFlag}, } diff --git a/cmd/login/list.go b/cmd/login/list.go index 99d8c7e..054bcfc 100644 --- a/cmd/login/list.go +++ b/cmd/login/list.go @@ -18,6 +18,7 @@ var CmdLoginList = cli.Command{ Aliases: []string{"ls"}, Usage: "List Gitea logins", Description: `List Gitea logins`, + ArgsUsage: " ", // command does not accept arguments Action: RunLoginList, Flags: []cli.Flag{&flags.OutputFlag}, } diff --git a/cmd/milestones/create.go b/cmd/milestones/create.go index e0f41d2..af64c96 100644 --- a/cmd/milestones/create.go +++ b/cmd/milestones/create.go @@ -23,6 +23,7 @@ var CmdMilestonesCreate = cli.Command{ Aliases: []string{"c"}, Usage: "Create an milestone on repository", Description: `Create an milestone on repository`, + ArgsUsage: " ", // command does not accept arguments Action: runMilestonesCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ diff --git a/cmd/milestones/list.go b/cmd/milestones/list.go index bf54e8c..e0a8afb 100644 --- a/cmd/milestones/list.go +++ b/cmd/milestones/list.go @@ -19,6 +19,7 @@ var CmdMilestonesList = cli.Command{ Aliases: []string{"ls"}, Usage: "List milestones of the repository", Description: `List milestones of the repository`, + ArgsUsage: " ", // command does not accept arguments Action: RunMilestonesList, Flags: append([]cli.Flag{ &cli.StringFlag{ diff --git a/cmd/notifications/list.go b/cmd/notifications/list.go index 7d96ab5..054d348 100644 --- a/cmd/notifications/list.go +++ b/cmd/notifications/list.go @@ -24,6 +24,7 @@ var CmdNotificationsList = cli.Command{ Aliases: []string{"list"}, Usage: "List notifications", Description: `List notifications`, + ArgsUsage: " ", // command does not accept arguments Action: RunNotificationsList, Flags: append([]cli.Flag{notifTypeFlag}, flags.NotificationFlags...), } diff --git a/cmd/organizations/list.go b/cmd/organizations/list.go index bc5219e..c64c9ca 100644 --- a/cmd/organizations/list.go +++ b/cmd/organizations/list.go @@ -19,6 +19,7 @@ var CmdOrganizationList = cli.Command{ Aliases: []string{"ls"}, Usage: "List Organizations", Description: "List users organizations", + ArgsUsage: " ", // command does not accept arguments Action: RunOrganizationList, Flags: append([]cli.Flag{ &flags.PaginationPageFlag, diff --git a/cmd/pulls/list.go b/cmd/pulls/list.go index b09f6bc..37b22a0 100644 --- a/cmd/pulls/list.go +++ b/cmd/pulls/list.go @@ -23,6 +23,7 @@ var CmdPullsList = cli.Command{ Aliases: []string{"ls"}, Usage: "List pull requests of the repository", Description: `List pull requests of the repository`, + ArgsUsage: " ", // command does not accept arguments Action: RunPullsList, Flags: append([]cli.Flag{pullFieldsFlag}, flags.PRListingFlags...), } diff --git a/cmd/releases.go b/cmd/releases.go index 126938e..d4e166e 100644 --- a/cmd/releases.go +++ b/cmd/releases.go @@ -19,6 +19,7 @@ var CmdReleases = cli.Command{ Category: catEntities, Usage: "Manage releases", Description: "Manage releases", + ArgsUsage: " ", // command does not accept arguments Action: releases.RunReleasesList, Subcommands: []*cli.Command{ &releases.CmdReleaseList, diff --git a/cmd/releases/create.go b/cmd/releases/create.go index 3fe3483..f2bbce2 100644 --- a/cmd/releases/create.go +++ b/cmd/releases/create.go @@ -22,7 +22,8 @@ var CmdReleaseCreate = cli.Command{ Name: "create", Aliases: []string{"c"}, Usage: "Create a release", - Description: `Create a release`, + Description: `Create a release for a new or existing git tag`, + ArgsUsage: "[]", Action: runReleaseCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ @@ -65,8 +66,16 @@ func runReleaseCreate(cmd *cli.Context) error { ctx := context.InitCommand(cmd) ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) + tag := ctx.String("tag") + if cmd.Args().Present() { + if len(tag) != 0 { + return fmt.Errorf("ambiguous arguments: provide tagname via --tag or argument, but not both") + } + tag = cmd.Args().First() + } + release, resp, err := ctx.Login.Client().CreateRelease(ctx.Owner, ctx.Repo, gitea.CreateReleaseOption{ - TagName: ctx.String("tag"), + TagName: tag, Target: ctx.String("target"), Title: ctx.String("title"), Note: ctx.String("note"), diff --git a/cmd/releases/list.go b/cmd/releases/list.go index c5e80d3..ac34ce1 100644 --- a/cmd/releases/list.go +++ b/cmd/releases/list.go @@ -21,6 +21,7 @@ var CmdReleaseList = cli.Command{ Aliases: []string{"ls"}, Usage: "List Releases", Description: "List Releases", + ArgsUsage: " ", // command does not accept arguments Action: RunReleasesList, Flags: append([]cli.Flag{ &flags.PaginationPageFlag, diff --git a/cmd/repos/create.go b/cmd/repos/create.go index a6f1547..fb74d75 100644 --- a/cmd/repos/create.go +++ b/cmd/repos/create.go @@ -21,6 +21,7 @@ var CmdRepoCreate = cli.Command{ Aliases: []string{"c"}, Usage: "Create a repository", Description: "Create a repository", + ArgsUsage: " ", // command does not accept arguments Action: runRepoCreate, Flags: append([]cli.Flag{ &cli.StringFlag{ diff --git a/cmd/repos/fork.go b/cmd/repos/fork.go index 53052bd..bae51e8 100644 --- a/cmd/repos/fork.go +++ b/cmd/repos/fork.go @@ -21,6 +21,7 @@ var CmdRepoFork = cli.Command{ Aliases: []string{"f"}, Usage: "Fork an existing repository", Description: "Create a repository from an existing repo", + ArgsUsage: " ", // command does not accept arguments Action: runRepoFork, Flags: append([]cli.Flag{ &cli.StringFlag{ diff --git a/cmd/whoami.go b/cmd/whoami.go index 1cd8b83..2b56828 100644 --- a/cmd/whoami.go +++ b/cmd/whoami.go @@ -17,6 +17,7 @@ var CmdWhoami = cli.Command{ Category: catSetup, Description: `For debugging purposes, show the user that is currently logged in.`, Usage: "Show current logged in user", + ArgsUsage: " ", // command does not accept arguments Action: func(cmd *cli.Context) error { ctx := context.InitCommand(cmd) client := ctx.Login.Client()