mirror of https://github.com/docker/cli.git
cmd/docker: move main() to the top
It was hidden half-way the file; let's move it to the top, where I'd expect to find it. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
c825db8a69
commit
11b2e871bc
|
@ -25,6 +25,31 @@ import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
dockerCli, err := command.NewDockerCli()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
logrus.SetOutput(dockerCli.Err())
|
||||||
|
|
||||||
|
if err := runDocker(dockerCli); err != nil {
|
||||||
|
if sterr, ok := err.(cli.StatusError); ok {
|
||||||
|
if sterr.Status != "" {
|
||||||
|
fmt.Fprintln(dockerCli.Err(), sterr.Status)
|
||||||
|
}
|
||||||
|
// StatusError should only be used for errors, and all errors should
|
||||||
|
// have a non-zero exit status, so never exit with 0
|
||||||
|
if sterr.StatusCode == 0 {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
os.Exit(sterr.StatusCode)
|
||||||
|
}
|
||||||
|
fmt.Fprintln(dockerCli.Err(), err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand {
|
func newDockerCommand(dockerCli *command.DockerCli) *cli.TopLevelCommand {
|
||||||
var (
|
var (
|
||||||
opts *cliflags.ClientOptions
|
opts *cliflags.ClientOptions
|
||||||
|
@ -309,31 +334,6 @@ func runDocker(dockerCli *command.DockerCli) error {
|
||||||
return cmd.Execute()
|
return cmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
|
||||||
dockerCli, err := command.NewDockerCli()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintln(os.Stderr, err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
logrus.SetOutput(dockerCli.Err())
|
|
||||||
|
|
||||||
if err := runDocker(dockerCli); err != nil {
|
|
||||||
if sterr, ok := err.(cli.StatusError); ok {
|
|
||||||
if sterr.Status != "" {
|
|
||||||
fmt.Fprintln(dockerCli.Err(), sterr.Status)
|
|
||||||
}
|
|
||||||
// StatusError should only be used for errors, and all errors should
|
|
||||||
// have a non-zero exit status, so never exit with 0
|
|
||||||
if sterr.StatusCode == 0 {
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
os.Exit(sterr.StatusCode)
|
|
||||||
}
|
|
||||||
fmt.Fprintln(dockerCli.Err(), err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type versionDetails interface {
|
type versionDetails interface {
|
||||||
CurrentVersion() string
|
CurrentVersion() string
|
||||||
ServerInfo() command.ServerInfo
|
ServerInfo() command.ServerInfo
|
||||||
|
|
Loading…
Reference in New Issue