Browse code

rebase and add some filters

Victor Vieux authored on 2013/11/01 11:21:35
Showing 3 changed files
... ...
@@ -1403,8 +1403,10 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
1403 1403
 }
1404 1404
 
1405 1405
 func (cli *DockerCli) CmdSearch(args ...string) error {
1406
-	cmd := Subcmd("search", "NAME", "Search the docker index for images")
1406
+	cmd := Subcmd("search", "TERM", "Search the docker index for images")
1407 1407
 	noTrunc := cmd.Bool("notrunc", false, "Don't truncate output")
1408
+	trusted := cmd.Bool("trusted", false, "Only show trusted builds")
1409
+	stars := cmd.Int("stars", 0, "Only displays with at least xxx stars")
1408 1410
 	if err := cmd.Parse(args); err != nil {
1409 1411
 		return nil
1410 1412
 	}
... ...
@@ -1425,7 +1427,6 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
1425 1425
 	if err != nil {
1426 1426
 		return err
1427 1427
 	}
1428
-	fmt.Fprintf(cli.out, "Found %d results matching your query (\"%s\")\n", len(outs), cmd.Arg(0))
1429 1428
 	w := tabwriter.NewWriter(cli.out, 10, 1, 3, ' ', 0)
1430 1429
 	fmt.Fprintf(w, "NAME\tDESCRIPTION\tSTARS\tOFFICIAL\tTRUSTED\n")
1431 1430
 	_, width := cli.getTtySize()
... ...
@@ -1435,6 +1436,9 @@ func (cli *DockerCli) CmdSearch(args ...string) error {
1435 1435
 		width = width - 10 - 54 //remote the first column
1436 1436
 	}
1437 1437
 	for _, out := range outs {
1438
+		if (*trusted && !out.IsTrusted) || (*stars > out.StarCount) {
1439
+			continue
1440
+		}
1438 1441
 		desc := strings.Replace(out.Description, "\n", " ", -1)
1439 1442
 		desc = strings.Replace(desc, "\r", " ", -1)
1440 1443
 		if !*noTrunc && len(desc) > width {
... ...
@@ -426,7 +426,7 @@ _docker_run()
426 426
 
427 427
 _docker_search()
428 428
 {
429
-	COMPREPLY=( $( compgen -W "-notrunc" -- "$cur" ) )
429
+	COMPREPLY=( $( compgen -W "-notrunc" "-stars" "-trusted" -- "$cur" ) )
430 430
 }
431 431
 
432 432
 _docker_start()
... ...
@@ -683,8 +683,11 @@ to the newly created container.
683 683
 
684 684
     Usage: docker search TERM
685 685
 
686
-    Searches for the TERM parameter on the Docker index and prints out
687
-    a list of repositories that match.
686
+    Search the docker index for images
687
+
688
+     -notrunc=false: Don't truncate output
689
+     -stars=0: Only displays with at least xxx stars
690
+     -trusted=false: Only show trusted builds
688 691
 
689 692
 .. _cli_start:
690 693