(prompt: &str, initial_text: Option<&str>)
| 83 | } |
| 84 | |
| 85 | pub fn input(prompt: &str, initial_text: Option<&str>) -> Result<String> { |
| 86 | if !stdout().is_terminal() { |
| 87 | warn!("called input while stdout is not a terminal"); |
| 88 | return Ok(String::new()); |
| 89 | } |
| 90 | |
| 91 | let theme = dialoguer_theme(); |
| 92 | let mut input = dialoguer::Input::with_theme(&theme).with_prompt(prompt); |
| 93 | |
| 94 | if let Some(initial_text) = initial_text { |
| 95 | input = input.with_initial_text(initial_text); |
| 96 | } |
| 97 | |
| 98 | Ok(input.interact_text()?) |
| 99 | } |
| 100 | |
| 101 | pub fn dialoguer_theme() -> ColorfulTheme { |
| 102 | ColorfulTheme { |
no test coverage detected