better hint for windows shells

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2015-04-30 10:36:38 -04:00
parent 9aa861ea55
commit 49686b9a91
No known key found for this signature in database
GPG Key ID: A519480096146526
2 changed files with 5 additions and 18 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
@ -658,8 +659,8 @@ func detectShell() (string, error) {
// attempt to get the SHELL env var
shell := filepath.Base(os.Getenv("SHELL"))
// none detected; check for windows env
if shell == "." && os.Getenv("windir") != "" {
log.Printf("On Windows, please specify either cmd or powershell with the --shell flag.\n\n")
if runtime.GOOS == "windows" {
log.Printf("On Windows, please specify either 'cmd' or 'powershell' with the --shell flag.\n\n")
return "", ErrUnknownShell
}

View File

@ -2,7 +2,6 @@ package commands
import (
"fmt"
"os"
"path/filepath"
log "github.com/Sirupsen/logrus"
@ -89,21 +88,8 @@ func cmdCreate(c *cli.Context) {
log.Fatalf("error setting active host: %v", err)
}
info := ""
userShell := filepath.Base(os.Getenv("SHELL"))
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)
}
info := fmt.Sprintf("%s env %s", c.App.Name, name)
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