diff --git a/components/cli/cobraadaptor/adaptor.go b/components/cli/cobraadaptor/adaptor.go index db16166f09..633844a12a 100644 --- a/components/cli/cobraadaptor/adaptor.go +++ b/components/cli/cobraadaptor/adaptor.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/docker/docker/api/client" + "github.com/docker/docker/api/client/image" "github.com/docker/docker/api/client/volume" "github.com/docker/docker/cli" cliflags "github.com/docker/docker/cli/flags" @@ -34,6 +35,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor { rootCmd.SetOutput(stdout) rootCmd.AddCommand( volume.NewVolumeCommand(dockerCli), + image.NewSearchCommand(dockerCli), ) rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage") diff --git a/components/cli/required.go b/components/cli/required.go index 94710374e6..b3ebb9ba9f 100644 --- a/components/cli/required.go +++ b/components/cli/required.go @@ -40,3 +40,19 @@ func RequiresMinArgs(min int) cobra.PositionalArgs { ) } } + +// ExactArgs returns an error if there is not the exact number of args +func ExactArgs(number int) cobra.PositionalArgs { + return func(cmd *cobra.Command, args []string) error { + if len(args) == number { + return nil + } + return fmt.Errorf( + "\"%s\" requires exactly %d argument(s).\n\nUsage: %s\n\n%s", + cmd.CommandPath(), + number, + cmd.UseLine(), + cmd.Short, + ) + } +} diff --git a/components/cli/usage.go b/components/cli/usage.go index 9ddc17326a..98d7fdf441 100644 --- a/components/cli/usage.go +++ b/components/cli/usage.go @@ -39,7 +39,6 @@ var DockerCommandUsage = []Command{ {"rmi", "Remove one or more images"}, {"run", "Run a command in a new container"}, {"save", "Save one or more images to a tar archive"}, - {"search", "Search the Docker Hub for images"}, {"start", "Start one or more stopped containers"}, {"stats", "Display a live stream of container(s) resource usage statistics"}, {"stop", "Stop a running container"},