use clap::Parser;
use dialoguer::theme::ColorfulTheme;
use std::io::Result;
#[derive(Debug, Parser)]
pub struct Confirm {
#[clap(short, long)]
message: String,
#[clap(short, long)]
cancel: bool,
#[clap(short, long)]
default: bool,
}
impl Confirm {
pub fn run(&self) -> Result<()> {
let theme = ColorfulTheme::default();
let mut input = dialoguer::Confirm::with_theme(&theme);
input.with_prompt(&self.message).default(self.default);
let ret = if self.cancel {
input.interact_opt()?
} else {
Some(input.interact()?)
};
let value = match ret {
Some(value) => value,
None => std::process::exit(1),
};
if value {
println!("true");
} else {
println!("false");
}
Ok(())
}
}