git_stk/commands/
restack.rs1use anyhow::Result;
2use clap::ArgAction;
3
4use crate::cli::{FetchMode, PushMode, UpdateRefsMode};
5use crate::commands::Run;
6
7#[derive(Debug, clap::Args)]
10pub struct Restack {
11 #[arg(long, action = ArgAction::SetTrue, conflicts_with = "no_fetch")]
14 fetch: bool,
15 #[arg(long, action = ArgAction::SetTrue)]
17 no_fetch: bool,
18 #[arg(long, action = ArgAction::SetTrue, conflicts_with = "no_update_refs")]
20 update_refs: bool,
21 #[arg(long, action = ArgAction::SetTrue)]
23 no_update_refs: bool,
24 #[arg(long, action = ArgAction::SetTrue, conflicts_with = "no_push")]
26 push: bool,
27 #[arg(long, action = ArgAction::SetTrue)]
29 no_push: bool,
30 #[arg(long, short = 'n', action = ArgAction::SetTrue)]
32 dry_run: bool,
33}
34
35impl Run for Restack {
36 fn run(self) -> Result<()> {
37 crate::stack::restack(
38 FetchMode::from_flags(self.fetch, self.no_fetch),
39 UpdateRefsMode::from_flags(self.update_refs, self.no_update_refs),
40 PushMode::from_flags(self.push, self.no_push),
41 self.dry_run,
42 )
43 }
44}
45
46#[derive(Debug, clap::Args)]
48pub struct Continue {}
49
50impl Run for Continue {
51 fn run(self) -> Result<()> {
52 crate::stack::continue_restack()
53 }
54}
55
56#[derive(Debug, clap::Args)]
58pub struct Abort {}
59
60impl Run for Abort {
61 fn run(self) -> Result<()> {
62 crate::stack::abort_restack()
63 }
64}