novel_api/common/utils/
input.rs

1use dialoguer::{theme::ColorfulTheme, Input, Password};
2
3use crate::Error;
4
5pub fn input<T>(prompt: T) -> Result<String, Error>
6where
7    T: AsRef<str>,
8{
9    Ok(Input::with_theme(&ColorfulTheme::default())
10        .with_prompt(prompt.as_ref())
11        .interact_text()?)
12}
13
14pub fn password<T>(prompt: T) -> Result<String, Error>
15where
16    T: AsRef<str>,
17{
18    Ok(Password::with_theme(&ColorfulTheme::default())
19        .with_prompt(prompt.as_ref())
20        .interact()?)
21}