MCPcopy Create free account
hub / github.com/docker/cli / newSearchCommand

Function newSearchCommand

cli/command/registry/search.go:32–57  ·  view source on GitHub ↗

newSearchCommand creates a new `docker search` command

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

30
31// newSearchCommand creates a new `docker search` command
32func newSearchCommand(dockerCLI command.Cli) *cobra.Command {
33 options := searchOptions{filter: opts.NewFilterOpt()}
34
35 cmd := &cobra.Command{
36 Use: "search [OPTIONS] TERM",
37 Short: "Search Docker Hub for images",
38 Args: cli.ExactArgs(1),
39 RunE: func(cmd *cobra.Command, args []string) error {
40 options.term = args[0]
41 return runSearch(cmd.Context(), dockerCLI, options)
42 },
43 Annotations: map[string]string{
44 "category-top": "10",
45 },
46 DisableFlagsInUseLine: true,
47 }
48
49 flags := cmd.Flags()
50
51 flags.BoolVar(&options.noTrunc, "no-trunc", false, "Don't truncate output")
52 flags.VarP(&options.filter, "filter", "f", "Filter output based on conditions provided")
53 flags.IntVar(&options.limit, "limit", 0, "Max number of search results")
54 flags.StringVar(&options.format, "format", "", "Pretty-print search using a Go template")
55
56 return cmd
57}
58
59func runSearch(ctx context.Context, dockerCli command.Cli, options searchOptions) error {
60 if _, ok := options.filter.Value()["is-automated"]; ok {

Callers

nothing calls this directly

Calls 1

runSearchFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…