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