Merge pull request #22372 from dnephin/cli_cleanup

Reorganize client and cli packages
This commit is contained in:
David Calavera 2016-04-29 17:31:39 -07:00
commit 3d58ff580f
3 changed files with 21 additions and 26 deletions

View File

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

View File

@ -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)

View File

@ -1,31 +1,13 @@
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
Description string
}
var dockerCommands = []Command{
// DockerCommandUsage lists the top level docker commands and their short usage
var DockerCommandUsage = []Command{
{"attach", "Attach to a running container"},
{"build", "Build an image from a Dockerfile"},
{"commit", "Create a new image from a container's changes"},
@ -74,7 +56,7 @@ var dockerCommands = []Command{
var DockerCommands = make(map[string]Command)
func init() {
for _, cmd := range dockerCommands {
for _, cmd := range DockerCommandUsage {
DockerCommands[cmd.Name] = cmd
}
}