Function age::cli_common::read_secret

source ·
pub fn read_secret(
    description: &str,
    prompt: &str,
    confirm: Option<&str>
) -> Result<SecretString>
Available on crate feature cli-common only.
Expand description

Requests a secret from the user.

If a pinentry binary is available on the system, it is used to request the secret. If not, we fall back to requesting directly in the CLI via a TTY.

This API does not take the secret directly from stdin, because it is specifically intended to take the secret from a human.

§Parameters

  • description is the primary information provided to the user about the secret being requested. It is printed in all cases.
  • prompt is a short phrase such as “Passphrase” or “PIN”. It is printed in front of the input field when pinentry is used.
  • confirm is an optional short phrase such as “Confirm passphrase”. Setting it enables input confirmation.
  • If confirm.is_some() then an empty secret is allowed.