1
0
Fork 0
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:
David Calavera 2013-07-27 10:00:36 -07:00
parent 594c818d85
commit d4f7039793

View file

@ -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