use clap::Args;
use uuid::Uuid;
#[derive(Args)]
pub struct UuidCmd {
#[arg(
short = 'x',
long,
help = "生成不带连字符的UUID",
default_value = "false"
)]
pub no_hyphens: bool,
}
impl UuidCmd {
pub fn execute(&self) {
println!("{}", self.generate());
}
fn generate(&self) -> String {
let uuid = Uuid::new_v4();
if self.no_hyphens {
uuid.to_string().replace("-", "")
} else {
uuid.to_string()
}
}
}