diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-07-21 11:28:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-21 11:28:19 +0200 |
commit | d0dbe52e76f3038777c3b50066e3636105387ca3 (patch) | |
tree | 4c159ed98a365300b6145bde03a06c29dcd21794 /cmd/dump_repo.go | |
parent | Remove commit status running and warning to align GitHub (#25839) (diff) | |
download | forgejo-d0dbe52e76f3038777c3b50066e3636105387ca3.tar.xz forgejo-d0dbe52e76f3038777c3b50066e3636105387ca3.zip |
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"
(https://github.com/go-gitea/gitea/pull/10912#issuecomment-1137543314),
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
Diffstat (limited to 'cmd/dump_repo.go')
-rw-r--r-- | cmd/dump_repo.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/cmd/dump_repo.go b/cmd/dump_repo.go index 0d3970466c..3a24cf6c5f 100644 --- a/cmd/dump_repo.go +++ b/cmd/dump_repo.go @@ -19,57 +19,58 @@ import ( "code.gitea.io/gitea/services/convert" "code.gitea.io/gitea/services/migrations" - "github.com/urfave/cli" + "github.com/urfave/cli/v2" ) // CmdDumpRepository represents the available dump repository sub-command. -var CmdDumpRepository = cli.Command{ +var CmdDumpRepository = &cli.Command{ Name: "dump-repo", Usage: "Dump the repository from git/github/gitea/gitlab", Description: "This is a command for dumping the repository data.", Action: runDumpRepository, Flags: []cli.Flag{ - cli.StringFlag{ + &cli.StringFlag{ Name: "git_service", Value: "", Usage: "Git service, git, github, gitea, gitlab. If clone_addr could be recognized, this could be ignored.", }, - cli.StringFlag{ - Name: "repo_dir, r", - Value: "./data", - Usage: "Repository dir path to store the data", + &cli.StringFlag{ + Name: "repo_dir", + Aliases: []string{"r"}, + Value: "./data", + Usage: "Repository dir path to store the data", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "clone_addr", Value: "", Usage: "The URL will be clone, currently could be a git/github/gitea/gitlab http/https URL", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "auth_username", Value: "", Usage: "The username to visit the clone_addr", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "auth_password", Value: "", Usage: "The password to visit the clone_addr", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "auth_token", Value: "", Usage: "The personal token to visit the clone_addr", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "owner_name", Value: "", Usage: "The data will be stored on a directory with owner name if not empty", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "repo_name", Value: "", Usage: "The data will be stored on a directory with repository name if not empty", }, - cli.StringFlag{ + &cli.StringFlag{ Name: "units", Value: "", Usage: `Which items will be migrated, one or more units should be separated as comma. |