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"}, Aliases: []string{"c"},
Usage: "Create an issue on repository", Usage: "Create an issue on repository",
Description: `Create an issue on repository`, Description: `Create an issue on repository`,
ArgsUsage: " ", // command does not accept arguments
Action: runIssuesCreate, Action: runIssuesCreate,
Flags: flags.IssuePREditFlags, Flags: flags.IssuePREditFlags,
} }

View File

@ -27,6 +27,7 @@ var CmdIssuesList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List issues of the repository", Usage: "List issues of the repository",
Description: `List issues of the repository`, Description: `List issues of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunIssuesList, Action: RunIssuesList,
Flags: append([]cli.Flag{issueFieldsFlag}, flags.IssueListingFlags...), Flags: append([]cli.Flag{issueFieldsFlag}, flags.IssueListingFlags...),
} }

View File

@ -18,6 +18,7 @@ var CmdLabels = cli.Command{
Category: catEntities, Category: catEntities,
Usage: "Manage issue labels", Usage: "Manage issue labels",
Description: `Manage issue labels`, Description: `Manage issue labels`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabels, Action: runLabels,
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
&labels.CmdLabelsList, &labels.CmdLabelsList,

View File

@ -23,6 +23,7 @@ var CmdLabelCreate = cli.Command{
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Create a label", Usage: "Create a label",
Description: `Create a label`, Description: `Create a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelCreate, Action: runLabelCreate,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -17,6 +17,7 @@ var CmdLabelDelete = cli.Command{
Aliases: []string{"rm"}, Aliases: []string{"rm"},
Usage: "Delete a label", Usage: "Delete a label",
Description: `Delete a label`, Description: `Delete a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelDelete, Action: runLabelDelete,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.IntFlag{ &cli.IntFlag{

View File

@ -20,6 +20,7 @@ var CmdLabelsList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List labels", Usage: "List labels",
Description: "List labels", Description: "List labels",
ArgsUsage: " ", // command does not accept arguments
Action: RunLabelsList, Action: RunLabelsList,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.BoolFlag{ &cli.BoolFlag{

View File

@ -17,6 +17,7 @@ var CmdLabelUpdate = cli.Command{
Name: "update", Name: "update",
Usage: "Update a label", Usage: "Update a label",
Description: `Update a label`, Description: `Update a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelUpdate, Action: runLabelUpdate,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.IntFlag{ &cli.IntFlag{

View File

@ -16,6 +16,7 @@ var CmdLoginAdd = cli.Command{
Name: "add", Name: "add",
Usage: "Add a Gitea login", Usage: "Add a Gitea login",
Description: `Add a Gitea login, without args it will create one interactively`, Description: `Add a Gitea login, without args it will create one interactively`,
ArgsUsage: " ", // command does not accept arguments
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "name", Name: "name",

View File

@ -18,6 +18,7 @@ var CmdLoginEdit = cli.Command{
Aliases: []string{"e"}, Aliases: []string{"e"},
Usage: "Edit Gitea logins", Usage: "Edit Gitea logins",
Description: `Edit Gitea logins`, Description: `Edit Gitea logins`,
ArgsUsage: " ", // command does not accept arguments
Action: runLoginEdit, Action: runLoginEdit,
Flags: []cli.Flag{&flags.OutputFlag}, Flags: []cli.Flag{&flags.OutputFlag},
} }

View File

@ -18,6 +18,7 @@ var CmdLoginList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List Gitea logins", Usage: "List Gitea logins",
Description: `List Gitea logins`, Description: `List Gitea logins`,
ArgsUsage: " ", // command does not accept arguments
Action: RunLoginList, Action: RunLoginList,
Flags: []cli.Flag{&flags.OutputFlag}, Flags: []cli.Flag{&flags.OutputFlag},
} }

View File

@ -23,6 +23,7 @@ var CmdMilestonesCreate = cli.Command{
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Create an milestone on repository", Usage: "Create an milestone on repository",
Description: `Create an milestone on repository`, Description: `Create an milestone on repository`,
ArgsUsage: " ", // command does not accept arguments
Action: runMilestonesCreate, Action: runMilestonesCreate,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -19,6 +19,7 @@ var CmdMilestonesList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List milestones of the repository", Usage: "List milestones of the repository",
Description: `List milestones of the repository`, Description: `List milestones of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunMilestonesList, Action: RunMilestonesList,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -24,6 +24,7 @@ var CmdNotificationsList = cli.Command{
Aliases: []string{"list"}, Aliases: []string{"list"},
Usage: "List notifications", Usage: "List notifications",
Description: `List notifications`, Description: `List notifications`,
ArgsUsage: " ", // command does not accept arguments
Action: RunNotificationsList, Action: RunNotificationsList,
Flags: append([]cli.Flag{notifTypeFlag}, flags.NotificationFlags...), Flags: append([]cli.Flag{notifTypeFlag}, flags.NotificationFlags...),
} }

View File

@ -19,6 +19,7 @@ var CmdOrganizationList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List Organizations", Usage: "List Organizations",
Description: "List users organizations", Description: "List users organizations",
ArgsUsage: " ", // command does not accept arguments
Action: RunOrganizationList, Action: RunOrganizationList,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&flags.PaginationPageFlag, &flags.PaginationPageFlag,

View File

@ -23,6 +23,7 @@ var CmdPullsList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List pull requests of the repository", Usage: "List pull requests of the repository",
Description: `List pull requests of the repository`, Description: `List pull requests of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunPullsList, Action: RunPullsList,
Flags: append([]cli.Flag{pullFieldsFlag}, flags.PRListingFlags...), Flags: append([]cli.Flag{pullFieldsFlag}, flags.PRListingFlags...),
} }

View File

@ -19,6 +19,7 @@ var CmdReleases = cli.Command{
Category: catEntities, Category: catEntities,
Usage: "Manage releases", Usage: "Manage releases",
Description: "Manage releases", Description: "Manage releases",
ArgsUsage: " ", // command does not accept arguments
Action: releases.RunReleasesList, Action: releases.RunReleasesList,
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
&releases.CmdReleaseList, &releases.CmdReleaseList,

View File

@ -22,7 +22,8 @@ var CmdReleaseCreate = cli.Command{
Name: "create", Name: "create",
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Create a release", Usage: "Create a release",
Description: `Create a release`, Description: `Create a release for a new or existing git tag`,
ArgsUsage: "[<tag>]",
Action: runReleaseCreate, Action: runReleaseCreate,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
@ -65,8 +66,16 @@ func runReleaseCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd) ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) 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{ release, resp, err := ctx.Login.Client().CreateRelease(ctx.Owner, ctx.Repo, gitea.CreateReleaseOption{
TagName: ctx.String("tag"), TagName: tag,
Target: ctx.String("target"), Target: ctx.String("target"),
Title: ctx.String("title"), Title: ctx.String("title"),
Note: ctx.String("note"), Note: ctx.String("note"),

View File

@ -21,6 +21,7 @@ var CmdReleaseList = cli.Command{
Aliases: []string{"ls"}, Aliases: []string{"ls"},
Usage: "List Releases", Usage: "List Releases",
Description: "List Releases", Description: "List Releases",
ArgsUsage: " ", // command does not accept arguments
Action: RunReleasesList, Action: RunReleasesList,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&flags.PaginationPageFlag, &flags.PaginationPageFlag,

View File

@ -21,6 +21,7 @@ var CmdRepoCreate = cli.Command{
Aliases: []string{"c"}, Aliases: []string{"c"},
Usage: "Create a repository", Usage: "Create a repository",
Description: "Create a repository", Description: "Create a repository",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoCreate, Action: runRepoCreate,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -21,6 +21,7 @@ var CmdRepoFork = cli.Command{
Aliases: []string{"f"}, Aliases: []string{"f"},
Usage: "Fork an existing repository", Usage: "Fork an existing repository",
Description: "Create a repository from an existing repo", Description: "Create a repository from an existing repo",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoFork, Action: runRepoFork,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
&cli.StringFlag{ &cli.StringFlag{

View File

@ -17,6 +17,7 @@ var CmdWhoami = cli.Command{
Category: catSetup, Category: catSetup,
Description: `For debugging purposes, show the user that is currently logged in.`, Description: `For debugging purposes, show the user that is currently logged in.`,
Usage: "Show current logged in user", Usage: "Show current logged in user",
ArgsUsage: " ", // command does not accept arguments
Action: func(cmd *cli.Context) error { Action: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd) ctx := context.InitCommand(cmd)
client := ctx.Login.Client() client := ctx.Login.Client()