1use anyhow::Result;
2use clap::ArgAction;
3
4use crate::commands::Run;
5
6#[derive(Debug, clap::Args)]
8pub struct New {
9 branch: String,
11 #[arg(long, conflicts_with = "prepend")]
13 insert: bool,
14 #[arg(long, conflicts_with = "insert")]
16 prepend: bool,
17 #[arg(long, short = 'n', action = ArgAction::SetTrue)]
20 dry_run: bool,
21}
22
23impl Run for New {
24 fn run(self) -> Result<()> {
25 if self.insert {
26 crate::stack::insert_branch(&self.branch, self.dry_run)
27 } else if self.prepend {
28 crate::stack::prepend_branch(&self.branch, self.dry_run)
29 } else {
30 crate::stack::create_branch(&self.branch, self.dry_run)
31 }
32 }
33}