use anyhow::Result;
use clap::ArgAction;
use crate::commands::Run;
#[derive(Debug, clap::Args)]
pub struct New {
branch: String,
#[arg(long, conflicts_with = "prepend")]
insert: bool,
#[arg(long, conflicts_with = "insert")]
prepend: bool,
#[arg(long, short = 'n', action = ArgAction::SetTrue)]
dry_run: bool,
}
impl Run for New {
fn run(self) -> Result<()> {
if self.insert {
crate::stack::insert_branch(&self.branch, self.dry_run)
} else if self.prepend {
crate::stack::prepend_branch(&self.branch, self.dry_run)
} else {
crate::stack::create_branch(&self.branch, self.dry_run)
}
}
}