use clap::Parser;
use dialoguer::theme::ColorfulTheme;
use std::io::Result;
#[derive(Debug, Parser)]
pub struct Secret {
#[clap(short, long)]
message: String,
#[clap(short, long, requires = "error")]
confirm: Option<String>,
#[clap(short, long, requires = "confirm")]
error: Option<String>,
#[clap(short, long)]
allow_empty: bool,
}
impl Secret {
pub fn run(&self) -> Result<()> {
let theme = ColorfulTheme::default();
let mut input = dialoguer::Password::with_theme(&theme);
input
.with_prompt(&self.message)
.allow_empty_password(self.allow_empty);
if self.confirm.is_some() {
input.with_confirmation(self.confirm.as_ref().unwrap(), self.error.as_ref().unwrap());
}
let value = input.interact()?;
println!("{}", value);
Ok(())
}
}