mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Do not show empty parenthesis if the default configuration is missing.
This commit is contained in:
parent
594c818d85
commit
d4f7039793
1 changed files with 10 additions and 2 deletions
12
commands.go
12
commands.go
|
@ -314,13 +314,21 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
|
|||
email string
|
||||
)
|
||||
|
||||
var promptDefault = func(stdout io.Writer, 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(cli.out, "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(cli.out, "Email", authconfig.Email)
|
||||
email = readAndEchoString(cli.in, cli.out)
|
||||
if email == "" {
|
||||
email = authconfig.Email
|
||||
|
|
Loading…
Reference in a new issue