diff --git a/commands.go b/commands.go index ee87781e9..51733035c 100644 --- a/commands.go +++ b/commands.go @@ -1403,8 +1403,10 @@ func (cli *DockerCli) CmdAttach(args ...string) error { } func (cli *DockerCli) CmdSearch(args ...string) error { - cmd := Subcmd("search", "NAME", "Search the docker index for images") + cmd := Subcmd("search", "TERM", "Search the docker index for images") noTrunc := cmd.Bool("notrunc", false, "Don't truncate output") + trusted := cmd.Bool("trusted", false, "Only show trusted builds") + stars := cmd.Int("stars", 0, "Only displays with at least xxx stars") if err := cmd.Parse(args); err != nil { return nil } @@ -1425,7 +1427,6 @@ func (cli *DockerCli) CmdSearch(args ...string) error { if err != nil { return err } - fmt.Fprintf(cli.out, "Found %d results matching your query (\"%s\")\n", len(outs), cmd.Arg(0)) w := tabwriter.NewWriter(cli.out, 10, 1, 3, ' ', 0) fmt.Fprintf(w, "NAME\tDESCRIPTION\tSTARS\tOFFICIAL\tTRUSTED\n") _, width := cli.getTtySize() @@ -1435,6 +1436,9 @@ func (cli *DockerCli) CmdSearch(args ...string) error { width = width - 10 - 54 //remote the first column } for _, out := range outs { + if (*trusted && !out.IsTrusted) || (*stars > out.StarCount) { + continue + } desc := strings.Replace(out.Description, "\n", " ", -1) desc = strings.Replace(desc, "\r", " ", -1) if !*noTrunc && len(desc) > width { diff --git a/contrib/completion/bash/docker b/contrib/completion/bash/docker index 5a91ab0f1..8e535285e 100755 --- a/contrib/completion/bash/docker +++ b/contrib/completion/bash/docker @@ -426,7 +426,7 @@ _docker_run() _docker_search() { - COMPREPLY=( $( compgen -W "-notrunc" -- "$cur" ) ) + COMPREPLY=( $( compgen -W "-notrunc" "-stars" "-trusted" -- "$cur" ) ) } _docker_start() diff --git a/docs/sources/commandline/cli.rst b/docs/sources/commandline/cli.rst index c6579da35..3256310b0 100644 --- a/docs/sources/commandline/cli.rst +++ b/docs/sources/commandline/cli.rst @@ -683,8 +683,11 @@ to the newly created container. Usage: docker search TERM - Searches for the TERM parameter on the Docker index and prints out - a list of repositories that match. + Search the docker index for images + + -notrunc=false: Don't truncate output + -stars=0: Only displays with at least xxx stars + -trusted=false: Only show trusted builds .. _cli_start: