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 <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-04-21 17:51:28 -04:00
parent 0c4f21fee3
commit a5c08fdbf0
3 changed files with 18 additions and 24 deletions

View File

@ -1,4 +1,4 @@
package cli package flags
import flag "github.com/docker/docker/pkg/mflag" import flag "github.com/docker/docker/pkg/mflag"

View File

@ -6,7 +6,6 @@ import (
"path/filepath" "path/filepath"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/cli"
"github.com/docker/docker/cliconfig" "github.com/docker/docker/cliconfig"
"github.com/docker/docker/opts" "github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag" flag "github.com/docker/docker/pkg/mflag"
@ -31,9 +30,23 @@ var (
dockerTLSVerify = os.Getenv("DOCKER_TLS_VERIFY") != "" 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 // InitCommonFlags initializes flags common to both client and daemon
func InitCommonFlags() *cli.CommonFlags { func InitCommonFlags() *CommonFlags {
var commonFlags = &cli.CommonFlags{FlagSet: new(flag.FlagSet)} var commonFlags = &CommonFlags{FlagSet: new(flag.FlagSet)}
if dockerCertPath == "" { if dockerCertPath == "" {
dockerCertPath = cliconfig.ConfigDir() dockerCertPath = cliconfig.ConfigDir()
@ -60,7 +73,7 @@ func InitCommonFlags() *cli.CommonFlags {
return commonFlags return commonFlags
} }
func postParseCommon(commonFlags *cli.CommonFlags) { func postParseCommon(commonFlags *CommonFlags) {
cmd := commonFlags.FlagSet cmd := commonFlags.FlagSet
SetDaemonLogLevel(commonFlags.LogLevel) SetDaemonLogLevel(commonFlags.LogLevel)

View File

@ -1,24 +1,5 @@
package cli 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 // Command is the struct containing the command name and description
type Command struct { type Command struct {
Name string Name string