use super::theme::ColoredTheme;
use dialoguer;
use std::io::Result;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct Input {
#[structopt(short, long)]
message: String,
#[structopt(short, long)]
default: Option<String>,
#[structopt(short, long, conflicts_with = "default")]
allow_empty: bool,
}
impl Input {
pub fn run(&self) -> Result<()> {
let theme = ColoredTheme::default();
let mut input = dialoguer::Input::<String>::with_theme(&theme);
input
.with_prompt(&self.message)
.allow_empty(self.allow_empty);
if self.default.is_some() {
input.default(self.default.as_ref().unwrap().to_string());
}
let value = input.interact()?;
println!("{}", value);
Ok(())
}
}