mirror of
https://github.com/docker/docs.git
synced 2026-04-13 14:56:12 +07:00
Merge pull request #1322 from calavera/prompt_without_defaults
Do not show empty parenthesis if the default configuration is missing.
This commit is contained in:
12
commands.go
12
commands.go
@@ -314,13 +314,21 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
|
||||
email string
|
||||
)
|
||||
|
||||
var promptDefault = func(prompt string, configDefault string) {
|
||||
if configDefault == "" {
|
||||
fmt.Fprintf(cli.out, "%s: ", prompt)
|
||||
} else {
|
||||
fmt.Fprintf(cli.out, "%s (%s): ", prompt, configDefault)
|
||||
}
|
||||
}
|
||||
|
||||
authconfig, ok := cli.configFile.Configs[auth.IndexServerAddress()]
|
||||
if !ok {
|
||||
authconfig = auth.AuthConfig{}
|
||||
}
|
||||
|
||||
if *flUsername == "" {
|
||||
fmt.Fprintf(cli.out, "Username (%s): ", authconfig.Username)
|
||||
promptDefault("Username", authconfig.Username)
|
||||
username = readAndEchoString(cli.in, cli.out)
|
||||
if username == "" {
|
||||
username = authconfig.Username
|
||||
@@ -340,7 +348,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
|
||||
}
|
||||
|
||||
if *flEmail == "" {
|
||||
fmt.Fprintf(cli.out, "Email (%s): ", authconfig.Email)
|
||||
promptDefault("Email", authconfig.Email)
|
||||
email = readAndEchoString(cli.in, cli.out)
|
||||
if email == "" {
|
||||
email = authconfig.Email
|
||||
|
||||
Reference in New Issue
Block a user