Skip to content

Commit

Permalink
crane: add catalog argument use annotation (#1473)
Browse files Browse the repository at this point in the history
* crane: add catalog argument use annotation

* crane: catalog examples and syntex update

* Update cmd/crane/cmd/catalog.go

Co-authored-by: Jason Hall <jason@chainguard.dev>

* crane: update docs for catalog

* crane: fix doc generation with args

Co-authored-by: Jason Hall <jason@chainguard.dev>
  • Loading branch information
brandtkeller and imjasonh committed Nov 3, 2022
1 parent 1711cef commit 353a117
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
19 changes: 15 additions & 4 deletions cmd/crane/cmd/catalog.go
Expand Up @@ -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...)
Expand Down
2 changes: 1 addition & 1 deletion cmd/crane/cmd/root.go
Expand Up @@ -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),
Expand Down
9 changes: 8 additions & 1 deletion cmd/crane/doc/crane_catalog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 353a117

Please sign in to comment.