mirror of https://github.com/docker/docs.git
better hint for windows shells
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
parent
9aa861ea55
commit
49686b9a91
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -658,8 +659,8 @@ func detectShell() (string, error) {
|
||||||
// attempt to get the SHELL env var
|
// attempt to get the SHELL env var
|
||||||
shell := filepath.Base(os.Getenv("SHELL"))
|
shell := filepath.Base(os.Getenv("SHELL"))
|
||||||
// none detected; check for windows env
|
// none detected; check for windows env
|
||||||
if shell == "." && os.Getenv("windir") != "" {
|
if runtime.GOOS == "windows" {
|
||||||
log.Printf("On Windows, please specify either cmd or powershell with the --shell flag.\n\n")
|
log.Printf("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n")
|
||||||
return "", ErrUnknownShell
|
return "", ErrUnknownShell
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
|
@ -89,21 +88,8 @@ func cmdCreate(c *cli.Context) {
|
||||||
log.Fatalf("error setting active host: %v", err)
|
log.Fatalf("error setting active host: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
info := ""
|
info := fmt.Sprintf("%s env %s", c.App.Name, name)
|
||||||
userShell := filepath.Base(os.Getenv("SHELL"))
|
log.Infof("To point your Docker client at it, run this in your shell: %s", info)
|
||||||
|
|
||||||
switch userShell {
|
|
||||||
case "fish":
|
|
||||||
info = fmt.Sprintf("%s env %s | source", c.App.Name, name)
|
|
||||||
default:
|
|
||||||
info = fmt.Sprintf(`eval "$(%s env %s)"`, c.App.Name, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Infof("%q has been created and is now the active machine.", name)
|
|
||||||
|
|
||||||
if info != "" {
|
|
||||||
log.Infof("To point your Docker client at it, run this in your shell: %s", info)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the user has specified a driver, they should not see the flags for all
|
// If the user has specified a driver, they should not see the flags for all
|
||||||
|
|
Loading…
Reference in New Issue