// PromptOptionalAndRetry works exactly like GetInputAndRetry, but also has
// a default option which will be used instead if the user simply presses enter.
510887
func (a Actor) PromptOptionalAndRetry(message, defaultOption string, checks ...InputCheck) (string, error) {
	for {
		input, err := a.PromptOptional(message, defaultOption, checks...)
		if err != nil {
			if err = a.confirmRetry(err); err != nil {
				return "", err
			}
			continue
		}
		return input, nil
	}
}
577571
func (orig OptionsConfiguration) RequiresRestartOnly() OptionsConfiguration {
	copy := orig
	blank := OptionsConfiguration{}
	util.CopyMatchingTag(&blank, &copy, "restart", func(v string) bool {
		if len(v) > 0 && v != "true" {
			panic(fmt.Sprintf(`unexpected tag value: %s. expected untagged or "true"`, v))
		}
		return v != "true"
	})
	return copy
}
879275
func Prompt(msg string) (string, error) {
	stdin, err := OpenConsole(os.O_RDONLY)
	if err != nil {
		return "", err
	}
	defer stdin.Close()

	fmt.Print(msg)
	scanner := bufio.NewScanner(stdin)
	scanner.Scan()
	if err := scanner.Err(); err != nil {
		return "", err
	}

	input := scanner.Text()
	if input == "" {
		return "", ErrCanceled
	}
	return input, nil
}
379323
func OptionAddKeyBind(b ...KeyBind) Option {
	return func(p *Prompt) error {
		p.keyBindings = append(p.keyBindings, b...)
		return nil
	}
}
339728
func OptionGeneric(generic map[string]interface{}) SandboxOption {
	return func(sb *sandbox) {
		if sb.config.generic == nil {
			sb.config.generic = make(map[string]interface{}, len(generic))
		}
		for k, v := range generic {
			sb.config.generic[k] = v
		}
	}
}
178130
func PromptPassword(entity string) string {
	for {
		value := prompt.PasswordMasked(entity)
		if value != "" {
			return value
		}
		logger.Printf("%s cannot be empty", entity)
	}
}
737920
func (prompt *Prompt) Prompt() (*dbus.Variant, error) {
  // prompts are asynchronous so we connect to the signal
  // and block with a channel until we get a response
  c := make(chan *dbus.Signal, 10)
  defer close(c)

  prompt.conn.Signal(c)
  defer prompt.conn.RemoveSignal(c)

  err := prompt.dbus.Call("org.freedesktop.Secret.Prompt.Prompt", 0, "").Store()
  if err != nil {
    return &dbus.Variant{}, err
  }

  for {
    if result := <-c; result.Path == prompt.Path() {
      value := result.Body[1].(dbus.Variant)
      return &value, nil
    }
  }
}
1005785
func OptionSuggestionBGColor(x Color) Option {
	return func(p *Prompt) error {
		p.renderer.suggestionBGColor = x
		return nil
	}
}
720980
func (u *Updater) promptForUpdateAction(ctx Context, update Update, options UpdateOptions) (UpdatePromptResponse, error) {
	u.log.Debug("Prompt for update")

	auto, autoSet := u.config.GetUpdateAuto()
	autoOverride := u.config.GetUpdateAutoOverride()
	u.log.Debugf("Auto update: %s (set=%s autoOverride=%s)", strconv.FormatBool(auto), strconv.FormatBool(autoSet), strconv.FormatBool(autoOverride))
	if auto && !autoOverride {
		if !ctx.IsCheckCommand() {
			// If there's an error getting active status, we'll just update
			isActive, err := u.checkUserActive(ctx)
			if err == nil && isActive {
				return UpdatePromptResponse{UpdateActionUIBusy, false, 0}, nil
			}
			u.guiBusyCount = 0
		}
		return UpdatePromptResponse{UpdateActionAuto, false, 0}, nil
	}

	updateUI := ctx.GetUpdateUI()

	// If auto update never set, default to true
	autoUpdate := auto || !autoSet
	promptOptions := UpdatePromptOptions{AutoUpdate: autoUpdate}
	updatePromptResponse, err := updateUI.UpdatePrompt(update, options, promptOptions)
	if err != nil {
		return UpdatePromptResponse{UpdateActionError, false, 0}, err
	}
	if updatePromptResponse == nil {
		return UpdatePromptResponse{UpdateActionError, false, 0}, fmt.Errorf("No response")
	}

	if updatePromptResponse.Action != UpdateActionContinue {
		u.log.Debugf("Update prompt response: %#v", updatePromptResponse)
		if err := u.config.SetUpdateAuto(updatePromptResponse.AutoUpdate); err != nil {
			u.log.Warningf("Error setting auto preference: %s", err)
			ctx.ReportError(configErr(fmt.Errorf("Error setting auto preference: %s", err)), &update, options)
		}
	}

	return *updatePromptResponse, nil
}
279539
func (p *Pollster) EnterOptional(valueName string) (string, error) {
	return QueryVerify("Enter "+valueName+" (optional): ", p.scanner, p.out, p.errOut, nil)
}
1107737
func Prompt(question string, validators ...ValidatorFunction) (out interface{}) {
	for {
		fmt.Printf("[?] %s: ", question)

		input, err := getInput()
		if err != nil {
			log.Fatal(err)
		}

		var validatorError error
		for _, validator := range validators {
			out, err = validator(input)
			if err != nil {
				validatorError = err
				break
			}
		}

		if validatorError == nil {
			break
		}

		fmt.Printf("[!] Error: %s\n", validatorError.Error())
	}
	return
}
1228655
func (p *terminalPrompter) PromptInput(prompt string) (string, error) {
	if p.supported {
		p.rawMode.ApplyMode()
		defer p.normalMode.ApplyMode()
	} else {
		// liner tries to be smart about printing the prompt
		// and doesn't print anything if input is redirected.
		// Un-smart it by printing the prompt always.
		fmt.Print(prompt)
		prompt = ""
		defer fmt.Println()
	}
	return p.State.Prompt(prompt)
}
31397
func PromptPasswordRepeated(entity string) string {
	for {
		value := prompt.PasswordMasked(fmt.Sprintf("Choose %s", entity))
		if value == "" {
			logger.Fatal(fmt.Sprintf("Canceled %s input", entity))
			continue
		}
		repeated := prompt.PasswordMasked(fmt.Sprintf("Repeat %s", entity))
		if repeated != value {
			logger.Printf("Repeated %s does not match", entity)
			continue
		}
		return value
	}
}
719223
func (m *DefaultScriptSourceManager) InstallOptional(scripts []string, dstDir string) []api.InstallResult {
	result := []api.InstallResult{}
	for _, script := range scripts {
		installed := false
		failedSources := []string{}
		for _, e := range m.sources {
			detected := false
			h := e.(ScriptHandler)
			h.SetDestinationDir(dstDir)
			if r := h.Get(script); r != nil {
				if err := h.Install(r); err != nil {
					failedSources = append(failedSources, h.String())
					// all this means is this source didn't have this particular script
					glog.V(4).Infof("script %q found by the %s, but failed to install: %v", script, h, err)
				} else {
					r.FailedSources = failedSources
					result = append(result, *r)
					installed = true
					detected = true
					glog.V(4).Infof("Using %q installed from %q", script, r.URL)
				}
			}
			if detected {
				break
			}
		}
		if !installed {
			result = append(result, api.InstallResult{
				FailedSources: failedSources,
				Script:        script,
				Error:         fmt.Errorf("script %q not installed", script),
			})
		}
	}
	return result
}
90899
func PromptCredentials(username, password string) (string, string) {
	return PromptUsername(username), PromptPassword(password)
}
943431
func prompt(promptText string) string {
	fmt.Fprint(cmdmain.Stdout, promptText)
	sc := bufio.NewScanner(cmdmain.Stdin)
	sc.Scan()
	return strings.TrimSpace(sc.Text())
}
1279762
func (m *MinTerm) PromptPassword(prompt string) (string, error) {
	if !strings.HasSuffix(prompt, ": ") {
		prompt += ": "
	}
	return m.readSecret(prompt)
}