func (p *Prove) promptRemoteName(ctx *Context) error { // If the name is already supplied, there's no need to prompt. if len(p.arg.Username) > 0 { remoteNameNormalized, err := p.st.NormalizeRemoteName(p.G(), p.arg.Username) if err == nil { p.remoteNameNormalized = remoteNameNormalized } return err } // Prompt for the name, retrying if it's invalid. var normalizationError error for { un, err := ctx.ProveUI.PromptUsername(context.TODO(), keybase1.PromptUsernameArg{ Prompt: p.st.GetPrompt(), PrevError: libkb.ExportErrorAsStatus(normalizationError), }) if err != nil { // Errors here are conditions like EOF. Return them rather than retrying. return err } var remoteNameNormalized string remoteNameNormalized, normalizationError = p.st.NormalizeRemoteName(p.G(), un) if normalizationError == nil { p.remoteNameNormalized = remoteNameNormalized return nil } } }
func (p *Prove) promptRemoteName(ctx *Context) (err error) { p.username = p.arg.Username if len(p.username) == 0 { var prevErr error for len(p.username) == 0 && err == nil { var un string un, err = ctx.ProveUI.PromptUsername(context.TODO(), keybase1.PromptUsernameArg{ Prompt: p.st.GetPrompt(), PrevError: libkb.ExportErrorAsStatus(prevErr), }) if err == nil { prevErr = p.st.CheckUsername(un) if prevErr == nil { p.username = un } } } } else { err = p.st.CheckUsername(p.username) } return }