mirror of https://github.com/docker/cli.git
Use spf13/cobra for docker search
- Move image command search to `api/client/image/search.go` - Use cobra :) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
82c85e1e83
commit
bbefa88a8c
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/client"
|
"github.com/docker/docker/api/client"
|
||||||
|
"github.com/docker/docker/api/client/image"
|
||||||
"github.com/docker/docker/api/client/volume"
|
"github.com/docker/docker/api/client/volume"
|
||||||
"github.com/docker/docker/cli"
|
"github.com/docker/docker/cli"
|
||||||
cliflags "github.com/docker/docker/cli/flags"
|
cliflags "github.com/docker/docker/cli/flags"
|
||||||
|
@ -34,6 +35,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
|
||||||
rootCmd.SetOutput(stdout)
|
rootCmd.SetOutput(stdout)
|
||||||
rootCmd.AddCommand(
|
rootCmd.AddCommand(
|
||||||
volume.NewVolumeCommand(dockerCli),
|
volume.NewVolumeCommand(dockerCli),
|
||||||
|
image.NewSearchCommand(dockerCli),
|
||||||
)
|
)
|
||||||
|
|
||||||
rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage")
|
rootCmd.PersistentFlags().BoolP("help", "h", false, "Print usage")
|
||||||
|
|
16
required.go
16
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,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
1
usage.go
1
usage.go
|
@ -39,7 +39,6 @@ var DockerCommandUsage = []Command{
|
||||||
{"rmi", "Remove one or more images"},
|
{"rmi", "Remove one or more images"},
|
||||||
{"run", "Run a command in a new container"},
|
{"run", "Run a command in a new container"},
|
||||||
{"save", "Save one or more images to a tar archive"},
|
{"save", "Save one or more images to a tar archive"},
|
||||||
{"search", "Search the Docker Hub for images"},
|
|
||||||
{"start", "Start one or more stopped containers"},
|
{"start", "Start one or more stopped containers"},
|
||||||
{"stats", "Display a live stream of container(s) resource usage statistics"},
|
{"stats", "Display a live stream of container(s) resource usage statistics"},
|
||||||
{"stop", "Stop a running container"},
|
{"stop", "Stop a running container"},
|
||||||
|
|
Loading…
Reference in New Issue