1use anyhow::Result;
2use clap_complete::engine::ArgValueCompleter;
3
4use crate::commands::Run;
5use crate::completions;
6
7#[derive(Debug, clap::Args)]
9pub struct Up {
10 #[arg(add = ArgValueCompleter::new(completions::child_branch_candidates))]
11 branch: Option<String>,
12 #[arg(long)]
16 from_path: bool,
17}
18
19impl Run for Up {
20 fn run(self) -> Result<()> {
21 crate::stack::checkout_child(self.branch.as_deref(), self.nav_output())
22 }
23}
24
25impl Up {
26 fn nav_output(&self) -> crate::stack::NavOutput {
27 if self.from_path {
28 crate::stack::NavOutput::Path
29 } else {
30 crate::stack::NavOutput::Announce
31 }
32 }
33}