mirror of https://github.com/docker/cli.git
Fix tests and windows service.
Support args to RunCommand Fix docker help text test. Fix for ipv6 tests. Fix TLSverify option. Fix TestDaemonDiscoveryBackendConfigReload Use tempfile for another test. Restore missing flag. Fix tests for removal of shlex. Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
3b178887a7
commit
9af25060cd
|
@ -4,9 +4,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDaemonCommand() *cobra.Command {
|
func newDaemonCommand() *cobra.Command {
|
||||||
|
|
21
docker.go
21
docker.go
|
@ -19,13 +19,15 @@ import (
|
||||||
|
|
||||||
func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
|
func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
opts := cliflags.NewClientOptions()
|
opts := cliflags.NewClientOptions()
|
||||||
|
var flags *pflag.FlagSet
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "docker [OPTIONS] COMMAND [arg...]",
|
Use: "docker [OPTIONS] COMMAND [arg...]",
|
||||||
Short: "A self-sufficient runtime for containers.",
|
Short: "A self-sufficient runtime for containers.",
|
||||||
SilenceUsage: true,
|
SilenceUsage: true,
|
||||||
SilenceErrors: true,
|
SilenceErrors: true,
|
||||||
TraverseChildren: true,
|
TraverseChildren: true,
|
||||||
Args: cli.NoArgs,
|
Args: noArgs,
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
if opts.Version {
|
if opts.Version {
|
||||||
showVersion()
|
showVersion()
|
||||||
|
@ -35,13 +37,15 @@ func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
dockerPreRun(cmd.Flags(), opts)
|
// flags must be the top-level command flags, not cmd.Flags()
|
||||||
|
opts.Common.SetDefaultOptions(flags)
|
||||||
|
dockerPreRun(opts)
|
||||||
return dockerCli.Initialize(opts)
|
return dockerCli.Initialize(opts)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cli.SetupRootCommand(cmd)
|
cli.SetupRootCommand(cmd)
|
||||||
|
|
||||||
flags := cmd.Flags()
|
flags = cmd.Flags()
|
||||||
flags.BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit")
|
flags.BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit")
|
||||||
flags.StringVar(&opts.ConfigDir, "config", cliconfig.ConfigDir(), "Location of client config files")
|
flags.StringVar(&opts.ConfigDir, "config", cliconfig.ConfigDir(), "Location of client config files")
|
||||||
opts.Common.InstallFlags(flags)
|
opts.Common.InstallFlags(flags)
|
||||||
|
@ -53,6 +57,14 @@ func newDockerCommand(dockerCli *client.DockerCli) *cobra.Command {
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func noArgs(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf(
|
||||||
|
"docker: '%s' is not a docker command.\nSee 'docker --help'%s", args[0], ".")
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Set terminal emulation based on platform as required.
|
// Set terminal emulation based on platform as required.
|
||||||
stdin, stdout, stderr := term.StdStreams()
|
stdin, stdout, stderr := term.StdStreams()
|
||||||
|
@ -86,8 +98,7 @@ func showVersion() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dockerPreRun(flags *pflag.FlagSet, opts *cliflags.ClientOptions) {
|
func dockerPreRun(opts *cliflags.ClientOptions) {
|
||||||
opts.Common.SetDefaultOptions(flags)
|
|
||||||
cliflags.SetDaemonLogLevel(opts.Common.LogLevel)
|
cliflags.SetDaemonLogLevel(opts.Common.LogLevel)
|
||||||
|
|
||||||
if opts.ConfigDir != "" {
|
if opts.ConfigDir != "" {
|
||||||
|
|
Loading…
Reference in New Issue