mod internal;
use anyhow::Result;
#[derive(Debug, Clone, clap::Subcommand)]
pub enum VersionCommands {
Show {
#[arg(short, long)]
json: bool,
#[arg(short, long)]
components: bool,
},
Hotfix {
description: String,
},
}
pub fn execute(json: bool, components: bool) -> Result<()> {
show(json, components)
}
pub fn execute_subcommand(command: VersionCommands) -> Result<()> {
match command {
VersionCommands::Show { json, components } => show(json, components),
VersionCommands::Hotfix { description } => hotfix(&description),
}
}
pub fn show(json: bool, components: bool) -> Result<()> {
internal::show_version(json, components)
}
pub fn hotfix(description: &str) -> Result<()> {
internal::hotfix(description)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_version_commands_variants() {
let show = VersionCommands::Show {
json: false,
components: true,
};
assert!(matches!(show, VersionCommands::Show { .. }));
let hotfix = VersionCommands::Hotfix {
description: "fix critical bug".to_string(),
};
assert!(matches!(hotfix, VersionCommands::Hotfix { .. }));
}
}