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, conflicts_with_all = ["insert", "prepend"])]
21 worktree: bool,
22 #[arg(long, short = 'n', action = ArgAction::SetTrue)]
25 dry_run: bool,
26}
27
28impl Run for New {
29 fn run(self) -> Result<()> {
30 if self.worktree {
31 crate::stack::create_branch_in_worktree(&self.branch, self.dry_run)
32 } else if self.insert {
33 crate::stack::insert_branch(&self.branch, self.dry_run)
34 } else if self.prepend {
35 crate::stack::prepend_branch(&self.branch, self.dry_run)
36 } else {
37 crate::stack::create_branch(&self.branch, self.dry_run)
38 }
39 }
40}