Skip to main content

Crate use_prompt

Crate use_prompt 

Source
Expand description

§use-prompt

Prompt text and confirmation primitives for RustUse CLI-adjacent code.

This crate stores prompt text and parses yes/no confirmation answers. It does not implement an interactive UI loop, prompt renderer, or terminal framework.

§Example

use use_prompt::{PromptText, YesNoAnswer, parse_confirmation};

let prompt = PromptText::new("Continue?")?;
let answer = parse_confirmation("yes")?;

assert_eq!(prompt.as_str(), "Continue?");
assert_eq!(answer, YesNoAnswer::Yes);

§Scope

Use this crate for prompt vocabulary and confirmation parsing only.

Modules§

prelude
Commonly used prompt primitives.

Structs§

PromptText
Owned prompt text.

Enums§

ConfirmationParseError
Errors returned while parsing confirmation answers.
PromptTextError
Validation errors for prompt text.
YesNoAnswer
A primitive yes/no answer.

Functions§

is_no
Returns whether input parses as no.
is_yes
Returns whether input parses as yes.
parse_confirmation
Parses a yes/no confirmation answer.