Merge pull request #1322 from calavera/prompt_without_defaults
Do not show empty parenthesis if the default configuration is missing. Upstream-commit: 950d0312dccde9826ea1e4c26dafab0dc56a59bb Component: engine
This commit is contained in:
@ -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