Skip to content

Commit

Permalink
Refactor to use urfave/cli/v2 (#25959)
Browse files Browse the repository at this point in the history
Replace #10912

And there are many new tests to cover the CLI behavior

There were some concerns about the "option order in hook scripts"
(#10912 (comment)),
it's not a problem now. Because the hook script uses `/gitea hook
--config=/app.ini pre-receive` format. The "config" is a global option,
it can appear anywhere.

----

## ⚠️ BREAKING ⚠️

This PR does it best to avoid breaking anything. The major changes are:

* `gitea` itself won't accept web's options: `--install-port` / `--pid`
/ `--port` / `--quiet` / `--verbose` .... They are `web` sub-command's
options.
    * Use `./gitea web --pid ....` instead
* `./gitea` can still run the `web` sub-command as shorthand, with
default options
* The sub-command's options must follow the sub-command
* Before: `./gitea --sub-opt subcmd` might equal to `./gitea subcmd
--sub-opt` (well, might not ...)
    * After: only `./gitea subcmd --sub-opt` could be used
    * The global options like `--config` are not affected
  • Loading branch information
wxiaoguang committed Jul 21, 2023
1 parent 840830b commit d0dbe52
Show file tree
Hide file tree
Showing 41 changed files with 886 additions and 643 deletions.
11 changes: 8 additions & 3 deletions assets/go-licenses.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions cmd/actions.go
Expand Up @@ -9,30 +9,31 @@ import (
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/setting"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

var (
// CmdActions represents the available actions sub-commands.
CmdActions = cli.Command{
CmdActions = &cli.Command{
Name: "actions",
Usage: "",
Description: "Commands for managing Gitea Actions",
Subcommands: []cli.Command{
Subcommands: []*cli.Command{
subcmdActionsGenRunnerToken,
},
}

subcmdActionsGenRunnerToken = cli.Command{
subcmdActionsGenRunnerToken = &cli.Command{
Name: "generate-runner-token",
Usage: "Generate a new token for a runner to use to register with the server",
Action: runGenerateActionsRunnerToken,
Aliases: []string{"grt"},
Flags: []cli.Flag{
cli.StringFlag{
Name: "scope, s",
Value: "",
Usage: "{owner}[/{repo}] - leave empty for a global runner",
&cli.StringFlag{
Name: "scope",
Aliases: []string{"s"},
Value: "",
Usage: "{owner}[/{repo}] - leave empty for a global runner",
},
},
}
Expand Down

0 comments on commit d0dbe52

Please sign in to comment.