git_stk/commands/new.rs
1use anyhow::Result;
2
3use crate::commands::Run;
4
5/// Create a new child branch from the current branch.
6#[derive(Debug, clap::Args)]
7pub struct New {
8 branch: String,
9 /// Insert above the current branch, moving its children onto the new one.
10 #[arg(long, conflicts_with = "prepend")]
11 insert: bool,
12 /// Insert below the current branch, moving it onto the new one.
13 #[arg(long)]
14 prepend: bool,
15}
16
17impl Run for New {
18 fn run(self) -> Result<()> {
19 if self.insert {
20 crate::stack::insert_branch(&self.branch)
21 } else if self.prepend {
22 crate::stack::prepend_branch(&self.branch)
23 } else {
24 crate::stack::create_branch(&self.branch)
25 }
26 }
27}