Skip to main content

git_stk/
cli.rs

1use clap::{Parser, Subcommand};
2
3use crate::commands;
4
5#[derive(Debug, Parser)]
6#[command(name = "git-stk")]
7#[command(version)]
8#[command(about = "Git-native stacked branch workflow helper, with GitHub and GitLab integration")]
9pub struct Cli {
10    /// Pass raw git output through instead of showing it only on failure.
11    #[arg(long, short = 'v', global = true)]
12    pub verbose: bool,
13    #[command(subcommand)]
14    pub command: Command,
15}
16
17#[derive(Debug, Subcommand)]
18pub enum Command {
19    New(commands::new::New),
20    Parent(commands::parent::Parent),
21    Children(commands::children::Children),
22    Up(commands::up::Up),
23    Down(commands::down::Down),
24    Top(commands::top::Top),
25    Bottom(commands::bottom::Bottom),
26    List(commands::list::List),
27    Status(commands::status::Status),
28    Adopt(commands::adopt::Adopt),
29    Detach(commands::detach::Detach),
30    Rename(commands::rename::Rename),
31    Restack(commands::restack::Restack),
32    Continue(commands::restack::Continue),
33    Abort(commands::restack::Abort),
34    Provider(commands::provider::Provider),
35    Review(commands::review::Review),
36    Sync(commands::sync::Sync),
37    Merge(commands::merge::Merge),
38    Repair(commands::repair::Repair),
39    Submit(commands::submit::Submit),
40    Config(commands::config::Config),
41    Completions(commands::completions::Completions),
42    Guide(commands::guide::Guide),
43    Setup(commands::setup::Setup),
44    Upgrade(commands::upgrade::Upgrade),
45    Cleanup(commands::cleanup::Cleanup),
46}
47
48#[derive(Debug, Clone, Copy, Eq, PartialEq)]
49pub enum UpdateRefsMode {
50    Config,
51    Enabled,
52    Disabled,
53}
54
55impl UpdateRefsMode {
56    pub fn from_flags(update_refs: bool, no_update_refs: bool) -> Self {
57        match (update_refs, no_update_refs) {
58            (true, false) => Self::Enabled,
59            (false, true) => Self::Disabled,
60            _ => Self::Config,
61        }
62    }
63}
64
65#[derive(Debug, Clone, Copy, Eq, PartialEq)]
66pub enum PushMode {
67    Config,
68    Enabled,
69    Disabled,
70}
71
72impl PushMode {
73    pub fn from_flags(push: bool, no_push: bool) -> Self {
74        match (push, no_push) {
75            (true, false) => Self::Enabled,
76            (false, true) => Self::Disabled,
77            _ => Self::Config,
78        }
79    }
80}