2023-08-30 12:12:24 -05:00
|
|
|
//go:build search
|
|
|
|
// +build search
|
|
|
|
|
|
|
|
package cli
|
|
|
|
|
2023-09-08 07:12:47 -05:00
|
|
|
import (
|
2023-09-14 12:51:17 -05:00
|
|
|
"fmt"
|
|
|
|
|
2023-09-08 07:12:47 -05:00
|
|
|
"github.com/spf13/cobra"
|
2023-09-14 12:51:17 -05:00
|
|
|
|
|
|
|
"zotregistry.io/zot/pkg/cli/cmdflags"
|
2023-09-08 07:12:47 -05:00
|
|
|
)
|
2023-08-30 12:12:24 -05:00
|
|
|
|
|
|
|
func NewListReposCommand(searchService SearchService) *cobra.Command {
|
2023-09-14 12:51:17 -05:00
|
|
|
repoListSortFlag := cmdflags.RepoListSortFlag(cmdflags.SortByAlphabeticAsc)
|
|
|
|
|
2023-08-30 12:12:24 -05:00
|
|
|
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)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-09-14 12:51:17 -05:00
|
|
|
cmd.Flags().Var(&repoListSortFlag, cmdflags.SortByFlag,
|
|
|
|
fmt.Sprintf("Options for sorting the output: [%s]", cmdflags.RepoListSortOptionsStr()))
|
|
|
|
|
2023-08-30 12:12:24 -05:00
|
|
|
return cmd
|
|
|
|
}
|