0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00
zot/pkg/cli/client/repo_sub_cmd.go
Alexei Dodon 4e04be420e
refactor(cli): Move cmdflags package under pkg/cli/client (#1840)
Signed-off-by: Alexei Dodon <adodon@cisco.com>
2023-09-22 16:33:18 +03:00

34 lines
715 B
Go

//go:build search
// +build search
package client
import (
"fmt"
"github.com/spf13/cobra"
)
func NewListReposCommand(searchService SearchService) *cobra.Command {
repoListSortFlag := RepoListSortFlag(SortByAlphabeticAsc)
cmd := &cobra.Command{
Use: "list",
Short: "List all repositories",
Long: "List all repositories",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
searchConfig, err := GetSearchConfigFromFlags(cmd, searchService)
if err != nil {
return err
}
return SearchRepos(searchConfig)
},
}
cmd.Flags().Var(&repoListSortFlag, SortByFlag,
fmt.Sprintf("Options for sorting the output: [%s]", RepoListSortOptionsStr()))
return cmd
}