Merge pull request #23292 from yongtang/23211-spf13-cobra-images

Use spf13/cobra for docker images
This commit is contained in:
Sebastiaan van Stijn 2016-06-07 21:56:42 +02:00
commit e428ca60d1
3 changed files with 18 additions and 1 deletions

View File

@ -51,6 +51,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
container.NewUnpauseCommand(dockerCli),
container.NewWaitCommand(dockerCli),
image.NewHistoryCommand(dockerCli),
image.NewImagesCommand(dockerCli),
image.NewRemoveCommand(dockerCli),
image.NewSearchCommand(dockerCli),
image.NewImportCommand(dockerCli),

View File

@ -43,6 +43,23 @@ func RequiresMinArgs(min int) cobra.PositionalArgs {
}
}
// RequiresMaxArgs returns an error if there is not at most max args
func RequiresMaxArgs(max int) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {
if len(args) <= max {
return nil
}
return fmt.Errorf(
"\"%s\" requires at most %d argument(s).\nSee '%s --help'.\n\nUsage: %s\n\n%s",
cmd.CommandPath(),
max,
cmd.CommandPath(),
cmd.UseLine(),
cmd.Short,
)
}
}
// RequiresMinMaxArgs returns an error if there is not at least min args and at most max args
func RequiresMinMaxArgs(min int, max int) cobra.PositionalArgs {
return func(cmd *cobra.Command, args []string) error {

View File

@ -13,7 +13,6 @@ var DockerCommandUsage = []Command{
{"cp", "Copy files/folders between a container and the local filesystem"},
{"events", "Get real time events from the server"},
{"exec", "Run a command in a running container"},
{"images", "List images"},
{"info", "Display system-wide information"},
{"inspect", "Return low-level information on a container or image"},
{"load", "Load an image from a tar archive or STDIN"},