Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crane: add catalog argument use annotation #1473

Merged
merged 5 commits into from Nov 3, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions cmd/crane/cmd/catalog.go
Expand Up @@ -16,17 +16,29 @@ package cmd

import (
"fmt"
"os"
"strings"

"github.com/google/go-containerregistry/pkg/crane"
"github.com/spf13/cobra"
)

// NewCmdCatalog creates a new cobra.Command for the repos subcommand.
func NewCmdCatalog(options *[]crane.Option) *cobra.Command {
func NewCmdCatalog(options *[]crane.Option, argv ...string) *cobra.Command {

if len(argv) == 0 {
argv = []string{os.Args[0]}
}

baseCmd := strings.Join(argv, " ")
eg := fmt.Sprintf(` # list the repos for reg.example.com
$ %s catalog reg.example.com`, baseCmd)

return &cobra.Command{
Use: "catalog",
Short: "List the repos in a registry",
Args: cobra.ExactArgs(1),
Use: "catalog [REGISTRY]",
Short: "List the repos in a registry",
Example: eg,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
reg := args[0]
repos, err := crane.Catalog(reg, *options...)
Expand Down