From c15182b1a023aa47fc17f0dacd45403955cc1c16 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 21 Apr 2016 17:51:28 -0400 Subject: [PATCH] Cleanup the structure of the cli package. Move all flags into cli/flags Move usage help into cli/usage.go Signed-off-by: Daniel Nephin Upstream-commit: a5c08fdbf0a32a39f047812025d3219ee01c8015 Component: cli --- components/cli/{ => flags}/client.go | 2 +- components/cli/flags/common.go | 21 +++++++++++++++++---- components/cli/{common.go => usage.go} | 19 ------------------- 3 files changed, 18 insertions(+), 24 deletions(-) rename components/cli/{ => flags}/client.go (94%) rename components/cli/{common.go => usage.go} (86%) diff --git a/components/cli/client.go b/components/cli/flags/client.go similarity index 94% rename from components/cli/client.go rename to components/cli/flags/client.go index 6a82eb52a5..cc7309db4b 100644 --- a/components/cli/client.go +++ b/components/cli/flags/client.go @@ -1,4 +1,4 @@ -package cli +package flags import flag "github.com/docker/docker/pkg/mflag" diff --git a/components/cli/flags/common.go b/components/cli/flags/common.go index d23696979b..4726b04f2a 100644 --- a/components/cli/flags/common.go +++ b/components/cli/flags/common.go @@ -6,7 +6,6 @@ import ( "path/filepath" "github.com/Sirupsen/logrus" - "github.com/docker/docker/cli" "github.com/docker/docker/cliconfig" "github.com/docker/docker/opts" flag "github.com/docker/docker/pkg/mflag" @@ -31,9 +30,23 @@ var ( dockerTLSVerify = os.Getenv("DOCKER_TLS_VERIFY") != "" ) +// CommonFlags are flags common to both the client and the daemon. +type CommonFlags struct { + FlagSet *flag.FlagSet + PostParse func() + + Debug bool + Hosts []string + LogLevel string + TLS bool + TLSVerify bool + TLSOptions *tlsconfig.Options + TrustKey string +} + // InitCommonFlags initializes flags common to both client and daemon -func InitCommonFlags() *cli.CommonFlags { - var commonFlags = &cli.CommonFlags{FlagSet: new(flag.FlagSet)} +func InitCommonFlags() *CommonFlags { + var commonFlags = &CommonFlags{FlagSet: new(flag.FlagSet)} if dockerCertPath == "" { dockerCertPath = cliconfig.ConfigDir() @@ -60,7 +73,7 @@ func InitCommonFlags() *cli.CommonFlags { return commonFlags } -func postParseCommon(commonFlags *cli.CommonFlags) { +func postParseCommon(commonFlags *CommonFlags) { cmd := commonFlags.FlagSet SetDaemonLogLevel(commonFlags.LogLevel) diff --git a/components/cli/common.go b/components/cli/usage.go similarity index 86% rename from components/cli/common.go rename to components/cli/usage.go index 7f6a24ba1f..4b0eb0e0c3 100644 --- a/components/cli/common.go +++ b/components/cli/usage.go @@ -1,24 +1,5 @@ package cli -import ( - flag "github.com/docker/docker/pkg/mflag" - "github.com/docker/go-connections/tlsconfig" -) - -// CommonFlags represents flags that are common to both the client and the daemon. -type CommonFlags struct { - FlagSet *flag.FlagSet - PostParse func() - - Debug bool - Hosts []string - LogLevel string - TLS bool - TLSVerify bool - TLSOptions *tlsconfig.Options - TrustKey string -} - // Command is the struct containing the command name and description type Command struct { Name string