diff --git a/cmd/crane/cmd/catalog.go b/cmd/crane/cmd/catalog.go index 9e3d13fd6..0bfa0a9fc 100644 --- a/cmd/crane/cmd/catalog.go +++ b/cmd/crane/cmd/catalog.go @@ -16,17 +16,28 @@ 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...) diff --git a/cmd/crane/cmd/root.go b/cmd/crane/cmd/root.go index 5ff333b5b..9d4f2872e 100644 --- a/cmd/crane/cmd/root.go +++ b/cmd/crane/cmd/root.go @@ -96,7 +96,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { NewCmdAppend(&options), NewCmdAuth(options, "crane", "auth"), NewCmdBlob(&options), - NewCmdCatalog(&options), + NewCmdCatalog(&options, "crane"), NewCmdConfig(&options), NewCmdCopy(&options), NewCmdDelete(&options), diff --git a/cmd/crane/doc/crane_catalog.md b/cmd/crane/doc/crane_catalog.md index cf55bb6c9..99b81ad28 100644 --- a/cmd/crane/doc/crane_catalog.md +++ b/cmd/crane/doc/crane_catalog.md @@ -3,7 +3,14 @@ List the repos in a registry ``` -crane catalog [flags] +crane catalog [REGISTRY] [flags] +``` + +### Examples + +``` + # list the repos for reg.example.com + $ crane catalog reg.example.com ``` ### Options