diff --git a/crates/relicario-cli/src/prompt.rs b/crates/relicario-cli/src/prompt.rs index 6f3e52e..87c2d3a 100644 --- a/crates/relicario-cli/src/prompt.rs +++ b/crates/relicario-cli/src/prompt.rs @@ -1,13 +1,12 @@ //! Interactive prompt helpers for the CLI. //! -//! The `prompt`/`prompt_optional`/`prompt_secret` family reads from stdin / -//! the TTY; the `prompt_keep`/`prompt_keep_opt`/`prompt_yesno` variants are +//! `prompt_secret` reads a masked secret from the TTY (honouring +//! `RELICARIO_TEST_ITEM_SECRET` so integration tests without a TTY can inject +//! secrets); the `prompt_keep`/`prompt_keep_opt`/`prompt_yesno` variants are //! used by the edit handlers to keep current values when the user hits enter -//! at a blank prompt. `prompt_secret` honours `RELICARIO_TEST_ITEM_SECRET` -//! so integration tests (which don't have a TTY) can inject secrets. -//! `prompt_or_flag` and `prompt_or_flag_optional` thread a CLI-flag value -//! through the same path so command handlers can use one call site whether -//! the value came from the command line or from an interactive prompt. +//! at a blank prompt. `prompt_or_flag` and `prompt_or_flag_optional` thread a +//! CLI-flag value through the same path so command handlers can use one call +//! site whether the value came from the command line or an interactive prompt. use anyhow::Result; use std::io::BufRead; @@ -41,18 +40,6 @@ fn read_optional_line(reader: &mut R, label: &str) -> Result Result { - let stdin = std::io::stdin(); - let mut reader = std::io::BufReader::new(stdin.lock()); - read_required_line(&mut reader, label) -} - -pub(crate) fn prompt_optional(label: &str) -> Result> { - let stdin = std::io::stdin(); - let mut reader = std::io::BufReader::new(stdin.lock()); - read_optional_line(&mut reader, label) -} - pub(crate) fn prompt_keep(label: &str, current: &str) -> Result> { eprint!("{label} [{current}]: "); std::io::Write::flush(&mut std::io::stderr())?;