novel_api/common/utils/
input.rs

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