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    Absorb(commands::absorb::Absorb),
21    Parent(commands::parent::Parent),
22    Children(commands::children::Children),
23    Up(commands::up::Up),
24    Down(commands::down::Down),
25    Top(commands::top::Top),
26    Bottom(commands::bottom::Bottom),
27    List(commands::list::List),
28    Status(commands::status::Status),
29    Adopt(commands::adopt::Adopt),
30    Detach(commands::detach::Detach),
31    Rename(commands::rename::Rename),
32    Restack(commands::restack::Restack),
33    Run(commands::run::Run),
34    Continue(commands::restack::Continue),
35    Abort(commands::restack::Abort),
36    Undo(commands::undo::Undo),
37    Provider(commands::provider::Provider),
38    Review(commands::review::Review),
39    View(commands::view::View),
40    Sync(commands::sync::Sync),
41    Merge(commands::merge::Merge),
42    Repair(commands::repair::Repair),
43    Submit(commands::submit::Submit),
44    Config(commands::config::Config),
45    Completions(commands::completions::Completions),
46    Guide(commands::guide::Guide),
47    Setup(commands::setup::Setup),
48    Upgrade(commands::upgrade::Upgrade),
49    Cleanup(commands::cleanup::Cleanup),
50}
51
52#[derive(Debug, Clone, Copy, Eq, PartialEq)]
53pub enum UpdateRefsMode {
54    Config,
55    Enabled,
56    Disabled,
57}
58
59impl UpdateRefsMode {
60    pub fn from_flags(update_refs: bool, no_update_refs: bool) -> Self {
61        match (update_refs, no_update_refs) {
62            (true, false) => Self::Enabled,
63            (false, true) => Self::Disabled,
64            _ => Self::Config,
65        }
66    }
67}
68
69#[derive(Debug, Clone, Copy, Eq, PartialEq)]
70pub enum PushMode {
71    Config,
72    Enabled,
73    Disabled,
74}
75
76impl PushMode {
77    pub fn from_flags(push: bool, no_push: bool) -> Self {
78        match (push, no_push) {
79            (true, false) => Self::Enabled,
80            (false, true) => Self::Disabled,
81            _ => Self::Config,
82        }
83    }
84}