🐛 删除无用参数

This commit is contained in:
徐晓伟 2023-12-04 18:49:23 +08:00
parent e69f06f87d
commit 71f8df1dcf
5 changed files with 8 additions and 19 deletions

View File

@ -556,7 +556,6 @@ COPYRIGHT:
OPTIONS:
--base-url value 实例地址例如https://gitlab.xuxiaowei.com.cn/api/v4 (default: "https://gitlab.com/api/v4") [%CI_API_V4_URL%]
--token value your_access_token
--username value 用户名
--owned 当前用户明确拥有的项目。 (default: false)
--export-folder value 导出文件夹
--skip-project-path value [ --skip-project-path value ] 跳过项目路径

View File

@ -1,7 +1,6 @@
package constant
const (
Username = "username"
Token = "token"
BaseUrl = "base-url"
BaseUrlDefault = "https://gitlab.com/api/v4"

View File

@ -49,14 +49,6 @@ func BaseUrl() cli.Flag {
}
}
func Username(required bool) cli.Flag {
return &cli.StringFlag{
Name: constant.Username,
Usage: "用户名",
Required: required,
}
}
func Token(required bool) cli.Flag {
return &cli.StringFlag{
Name: constant.Token,

View File

@ -23,13 +23,12 @@ func ExportAll() *cli.Command {
"已包含:\n" +
"1. git 仓库\n" +
"2. wiki 仓库",
Flags: append(flag.CommonTokenRequired(), flag.Username(true), flag.Owned(true),
Flags: append(flag.CommonTokenRequired(), flag.Owned(true),
flag.ExportFolder(true), flag.SkipProjectPath(), flag.SkipProjectWikiPath()),
Action: func(context *cli.Context) error {
var baseUrl = context.String(constant.BaseUrl)
var token = context.String(constant.Token)
var username = context.String(constant.Username)
var owned = context.Bool(constant.Owned)
var exportFolder = context.String(constant.ExportFolder)
var skipProjectPaths = context.StringSlice(constant.SkipProjectPath)
@ -62,12 +61,12 @@ func ExportAll() *cli.Command {
for index, project := range projectList {
log.Printf("Project Index: %d, WebURL: %s", index, project.WebURL)
err = Repository(exportFolder, host, username, token, project, skipProjectPaths)
err = Repository(exportFolder, host, token, project, skipProjectPaths)
if err != nil {
return err
}
err = Wiki(exportFolder, host, username, token, project, skipProjectWikiPaths)
err = Wiki(exportFolder, host, token, project, skipProjectWikiPaths)
if err != nil {
return err
}
@ -80,7 +79,7 @@ func ExportAll() *cli.Command {
}
}
func Repository(exportFolder string, host string, username string, token string, project *gitlab.Project, skipProjectPaths []string) error {
func Repository(exportFolder string, host string, token string, project *gitlab.Project, skipProjectPaths []string) error {
c := contains(skipProjectPaths, project.PathWithNamespace)
if c {
@ -100,7 +99,7 @@ func Repository(exportFolder string, host string, username string, token string,
return err
}
userinfo := url.UserPassword(username, token)
userinfo := url.UserPassword("", token)
repoUrl.User = userinfo
cmd := exec.Command("git", "clone", repoUrl.String(), gitPath)
@ -120,7 +119,7 @@ func Repository(exportFolder string, host string, username string, token string,
return nil
}
func Wiki(exportFolder string, host string, username string, token string, project *gitlab.Project, skipProjectWikiPaths []string) error {
func Wiki(exportFolder string, host string, token string, project *gitlab.Project, skipProjectWikiPaths []string) error {
c := contains(skipProjectWikiPaths, project.PathWithNamespace)
if c {
@ -146,7 +145,7 @@ func Wiki(exportFolder string, host string, username string, token string, proje
return err
}
userinfo := url.UserPassword(username, token)
userinfo := url.UserPassword("", token)
repoUrl.User = userinfo
cmd := exec.Command("git", "clone", repoUrl.String(), wikiPath)

View File

@ -10,7 +10,7 @@ func Export() *cli.Command {
return &cli.Command{
Name: "mix-export",
Usage: "导出(混合命令,多接口命令)",
Flags: append(flag.Common(), flag.Username(false), flag.Owned(false),
Flags: append(flag.Common(), flag.Owned(false),
flag.ExportFolder(false), flag.SkipProjectPath(), flag.SkipProjectWikiPath()),
Subcommands: []*cli.Command{
ExportAll(),