Skip to content

Commit d0dbe52

Browse files
authoredJul 21, 2023
Refactor to use urfave/cli/v2 (#25959)
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
1 parent 840830b commit d0dbe52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+886
-643
lines changed
 

‎assets/go-licenses.json

+8-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cmd/actions.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,31 @@ import (
99
"code.gitea.io/gitea/modules/private"
1010
"code.gitea.io/gitea/modules/setting"
1111

12-
"github.com/urfave/cli"
12+
"github.com/urfave/cli/v2"
1313
)
1414

1515
var (
1616
// CmdActions represents the available actions sub-commands.
17-
CmdActions = cli.Command{
17+
CmdActions = &cli.Command{
1818
Name: "actions",
1919
Usage: "",
2020
Description: "Commands for managing Gitea Actions",
21-
Subcommands: []cli.Command{
21+
Subcommands: []*cli.Command{
2222
subcmdActionsGenRunnerToken,
2323
},
2424
}
2525

26-
subcmdActionsGenRunnerToken = cli.Command{
26+
subcmdActionsGenRunnerToken = &cli.Command{
2727
Name: "generate-runner-token",
2828
Usage: "Generate a new token for a runner to use to register with the server",
2929
Action: runGenerateActionsRunnerToken,
3030
Aliases: []string{"grt"},
3131
Flags: []cli.Flag{
32-
cli.StringFlag{
33-
Name: "scope, s",
34-
Value: "",
35-
Usage: "{owner}[/{repo}] - leave empty for a global runner",
32+
&cli.StringFlag{
33+
Name: "scope",
34+
Aliases: []string{"s"},
35+
Value: "",
36+
Usage: "{owner}[/{repo}] - leave empty for a global runner",
3637
},
3738
},
3839
}

0 commit comments

Comments
 (0)
Please sign in to comment.