Expand description
Interactive user-confirmation dialogs for auto-fixes.
prompt_user_confirmation asks a yes/no question and reads a single
keypress (no Enter required) with a 30 second timeout; the default is used
when the user presses Enter or the prompt expires. prompt_fix_selection
renders a checkbox list that is navigated with the arrow keys, toggled with
space and confirmed with Enter.
Both prompts are written against the KeyReader / PromptWriter
abstractions so the same logic is unit-testable with MockKeyReader and
CapturingWriter instead of a real terminal.
use limitless_cli::modules::interactive_prompt::{
prompt_user_confirmation_with, CapturingWriter, Key, MockKeyReader,
CONFIRM_TIMEOUT,
};
let mut reader = MockKeyReader::new(vec![Key::Enter]);
let mut writer = CapturingWriter::default();
let confirmed = prompt_user_confirmation_with(
"Copy .env.example to .env?",
true,
CONFIRM_TIMEOUT,
&mut reader,
&mut writer,
);
assert!(confirmed);
assert!(writer.output.contains("❓ Copy .env.example to .env? (Y/n) [y]"));Structs§
- Capturing
Writer - A
PromptWriterthat records everything written for assertions. - Fix
- One auto-fix candidate offered by the selection UI.
- Mock
KeyReader - A
KeyReaderthat replays a canned sequence of keys for tests. - Stdout
Writer - Writer backed by the real standard output.
- Terminal
KeyReader - Key reader backed by a real terminal via the
crosstermcrate.
Enums§
- Key
- A normalized key press that the prompts understand.
Constants§
- CONFIRM_
TIMEOUT - How long a confirmation prompt waits for input before using its default.
Traits§
- KeyReader
- Abstraction over the terminal so prompts can be driven by mock input.
- Prompt
Writer - Abstraction over the output stream so prompts can capture their text.
Functions§
- fixes_
from_ mentors - Builds a fix list from
mentor_messages-style suggestions. - prompt_
fix_ selection - Renders a checkbox list and returns the user-selected fixes.
- prompt_
fix_ selection_ with - Testable core of
prompt_fix_selection; see the module docs. - prompt_
user_ confirmation - Asks
messageas a yes/no question and returns the user’s decision. - prompt_
user_ confirmation_ with - Testable core of
prompt_user_confirmation; see the module docs.