项目:列出所有项目:当前用户明确拥有的项目

This commit is contained in:
徐晓伟 2024-03-09 17:54:38 +08:00
parent f2454e84f6
commit 9a00cb52ed
3 changed files with 7 additions and 4 deletions

View File

@ -544,6 +544,7 @@ 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
--owned 当前用户明确拥有的项目。 (default: false)
--sort value 按照 asc 或者 desc 排序 (default: "desc")
--page value 页码默认1中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination (default: 1)
--per-page value 每页列出的项目数默认20最大100中文文档 https://docs.gitlab.cn/jh/api/rest/index.html#pagination (default: 20)

View File

@ -15,12 +15,13 @@ func List() *cli.Command {
return &cli.Command{
Name: "list",
Usage: "列出所有项目",
Flags: append(flag.Common(), flag.Sort(), flag.Page(), flag.PerPage(), flag.PrintJson(), flag.PrintTime(),
flag.Search(), flag.SearchNamespaces(),
Flags: append(flag.Common(), flag.Owned(true), flag.Sort(), flag.Page(), flag.PerPage(),
flag.PrintJson(), flag.PrintTime(), flag.Search(), flag.SearchNamespaces(),
flag.OrderBy(OrderByUsage)),
Action: func(context *cli.Context) error {
var baseUrl = context.String(constant.BaseUrl)
var token = context.String(constant.Token)
var owned = context.Bool(constant.Owned)
var sort = context.String(constant.Sort)
var page = context.Int(constant.Page)
var perPage = context.Int(constant.PerPage)
@ -43,6 +44,7 @@ func List() *cli.Command {
Sort: &sort,
Search: &search,
SearchNamespaces: &searchNamespaces,
Owned: &owned,
OrderBy: &orderBy,
}
projects, response, err := gitClient.Projects.ListProjects(opt)

View File

@ -18,8 +18,8 @@ func Projects() *cli.Command {
Name: "project",
Aliases: []string{"projects", "p"},
Usage: "项目 API中文文档https://docs.gitlab.cn/jh/api/projects.html",
Flags: append(flag.Common(), flag.Sort(), flag.Page(), flag.PerPage(), flag.PrintJson(), flag.PrintTime(),
flag.Search(), flag.SearchNamespaces(),
Flags: append(flag.Common(), flag.Owned(false), flag.Sort(), flag.Page(), flag.PerPage(),
flag.PrintJson(), flag.PrintTime(), flag.Search(), flag.SearchNamespaces(),
flag.OrderBy(OrderByUsage)),
Subcommands: []*cli.Command{
List(),