mirror of https://github.com/docker/compose.git
Add default shellout to engine if no context specified
Improve CLI documentation Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
parent
3dac4df803
commit
a8403241e4
30
cmd/main.go
30
cmd/main.go
|
@ -30,7 +30,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/docker/api/context"
|
"github.com/docker/api/context"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -61,25 +63,43 @@ func main() {
|
||||||
context.ConfigFlag,
|
context.ConfigFlag,
|
||||||
context.ContextFlag,
|
context.ContextFlag,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app.Before = func(clix *cli.Context) error {
|
app.Before = func(clix *cli.Context) error {
|
||||||
if clix.GlobalBool("debug") {
|
if clix.GlobalBool("debug") {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
|
ctx, err := context.GetContext()
|
||||||
context, err := context.GetContext()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
fmt.Println(context.Metadata.Type)
|
if ctx.Metadata.Type == "Moby" {
|
||||||
// TODO select backend based on context.Metadata.Type or delegate to legacy CLI if == "Moby"
|
shellOutToDefaultEngine()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
// TODO select backend based on context.Metadata.Type
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
contextCommand,
|
contextCommand,
|
||||||
exampleCommand,
|
exampleCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Sort(cli.FlagsByName(app.Flags))
|
||||||
|
sort.Sort(cli.CommandsByName(app.Commands))
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shellOutToDefaultEngine() {
|
||||||
|
cmd :=exec.Command("/Applications/Docker.app/Contents/Resources/bin/docker", os.Args[1:]...)
|
||||||
|
cmd.Stdin = os.Stdin
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ var (
|
||||||
ConfigDir string
|
ConfigDir string
|
||||||
ConfigFlag = cli.StringFlag{
|
ConfigFlag = cli.StringFlag{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Usage: "Location of client config files",
|
Usage: "Location of client config files `DIRECTORY`",
|
||||||
EnvVar: "DOCKER_CONFIG",
|
EnvVar: "DOCKER_CONFIG",
|
||||||
Value: filepath.Join(homedir.Get(), configFileDir),
|
Value: filepath.Join(homedir.Get(), configFileDir),
|
||||||
Destination: &ConfigDir,
|
Destination: &ConfigDir,
|
||||||
|
@ -26,7 +26,7 @@ var (
|
||||||
ContextName string
|
ContextName string
|
||||||
ContextFlag = cli.StringFlag{
|
ContextFlag = cli.StringFlag{
|
||||||
Name: "context, c",
|
Name: "context, c",
|
||||||
Usage: `Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")`,
|
Usage: "Name of the context `CONTEXT` to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")",
|
||||||
EnvVar: "DOCKER_CONTEXT",
|
EnvVar: "DOCKER_CONTEXT",
|
||||||
Destination: &ContextName,
|
Destination: &ContextName,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue