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 <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/496
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: delvh <delvh@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin 2022-09-14 02:14:02 +08:00 committed by 6543
parent b8dbf899d2
commit 5e7c702e07
21 changed files with 31 additions and 2 deletions

View File

@ -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,
}

View File

@ -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...),
}

View File

@ -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,

View File

@ -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{

View File

@ -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{

View File

@ -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{

View File

@ -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{

View File

@ -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",

View File

@ -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},
}

View File

@ -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},
}

View File

@ -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{

View File

@ -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{

View File

@ -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...),
}

View File

@ -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,

View File

@ -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...),
}

View File

@ -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,

View File

@ -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: "[<tag>]",
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"),

View File

@ -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,

View File

@ -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{

View File

@ -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{

View File

@ -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()