mirror of https://github.com/docker/cli.git
Merge pull request #23286 from yongtang/23211-spf13-cobra-port
Use spf13/cobra for docker port
This commit is contained in:
commit
2002063bf2
|
@ -38,6 +38,7 @@ func NewCobraAdaptor(clientFlags *cliflags.ClientFlags) CobraAdaptor {
|
|||
container.NewDiffCommand(dockerCli),
|
||||
container.NewExportCommand(dockerCli),
|
||||
container.NewLogsCommand(dockerCli),
|
||||
container.NewPortCommand(dockerCli),
|
||||
container.NewRunCommand(dockerCli),
|
||||
container.NewStartCommand(dockerCli),
|
||||
container.NewStopCommand(dockerCli),
|
||||
|
|
18
required.go
18
required.go
|
@ -43,6 +43,24 @@ func RequiresMinArgs(min int) cobra.PositionalArgs {
|
|||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
if len(args) >= min && len(args) <= max {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"\"%s\" requires at least %d and at most %d argument(s).\nSee '%s --help'.\n\nUsage: %s\n\n%s",
|
||||
cmd.CommandPath(),
|
||||
min,
|
||||
max,
|
||||
cmd.CommandPath(),
|
||||
cmd.UseLine(),
|
||||
cmd.Short,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
|
|
1
usage.go
1
usage.go
|
@ -24,7 +24,6 @@ var DockerCommandUsage = []Command{
|
|||
{"login", "Log in to a Docker registry"},
|
||||
{"logout", "Log out from a Docker registry"},
|
||||
{"pause", "Pause all processes within a container"},
|
||||
{"port", "List port mappings or a specific mapping for the CONTAINER"},
|
||||
{"ps", "List containers"},
|
||||
{"pull", "Pull an image or a repository from a registry"},
|
||||
{"push", "Push an image or a repository to a registry"},
|
||||
|
|
Loading…
Reference in New Issue