1use clap::{ArgAction, Parser, Subcommand};
2
3#[derive(Debug, Parser)]
4#[command(name = "git-stk")]
5#[command(about = "Git-native stacked branch workflow helper, with GitHub and GitLab integration")]
6pub struct Cli {
7 #[command(subcommand)]
8 pub command: Command,
9}
10
11#[derive(Debug, Subcommand)]
12pub enum Command {
13 New { branch: String },
15 Parent { branch: Option<String> },
17 Children { branch: Option<String> },
19 Up,
21 Down { branch: Option<String> },
23 List,
25 Status { branch: Option<String> },
27 Adopt {
29 branch: String,
30 #[arg(long)]
31 parent: String,
32 },
33 Detach { branch: Option<String> },
35 Restack {
37 #[arg(long, action = ArgAction::SetTrue, conflicts_with = "no_update_refs")]
39 update_refs: bool,
40 #[arg(long, action = ArgAction::SetTrue)]
42 no_update_refs: bool,
43 },
44 Continue,
46 Abort,
48 Provider,
50 Review { branch: Option<String> },
52 Sync {
54 branch: Option<String>,
55 #[arg(long, action = ArgAction::SetTrue)]
57 dry_run: bool,
58 },
59 Submit {
61 branch: Option<String>,
62 #[arg(long, action = ArgAction::SetTrue)]
64 dry_run: bool,
65 #[arg(long, conflicts_with = "branch")]
67 stack: bool,
68 },
69 Cleanup {
71 branch: Option<String>,
72 #[arg(long, action = ArgAction::SetTrue)]
74 dry_run: bool,
75 #[arg(long, action = ArgAction::SetTrue)]
77 delete_branch: bool,
78 },
79}
80
81#[derive(Debug, Clone, Copy, Eq, PartialEq)]
82pub enum UpdateRefsMode {
83 Config,
84 Enabled,
85 Disabled,
86}
87
88impl UpdateRefsMode {
89 pub fn from_flags(update_refs: bool, no_update_refs: bool) -> Self {
90 match (update_refs, no_update_refs) {
91 (true, false) => Self::Enabled,
92 (false, true) => Self::Disabled,
93 _ => Self::Config,
94 }
95 }
96}