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")]
9#[command(after_help = "New to stacking? Run `git stk guide` for short interactive tours.")]
10pub struct Cli {
11    /// Pass raw git output through instead of showing it only on failure.
12    #[arg(long, short = 'v', global = true)]
13    pub verbose: bool,
14    #[command(subcommand)]
15    pub command: Command,
16}
17
18#[derive(Debug, Subcommand)]
19pub enum Command {
20    New(commands::new::New),
21    Absorb(commands::absorb::Absorb),
22    Parent(commands::parent::Parent),
23    Children(commands::children::Children),
24    Up(commands::up::Up),
25    Down(commands::down::Down),
26    Top(commands::top::Top),
27    Bottom(commands::bottom::Bottom),
28    List(commands::list::List),
29    Status(commands::status::Status),
30    Adopt(commands::adopt::Adopt),
31    Detach(commands::detach::Detach),
32    Rename(commands::rename::Rename),
33    Restack(commands::restack::Restack),
34    Run(commands::run::Run),
35    Continue(commands::restack::Continue),
36    Abort(commands::restack::Abort),
37    Undo(commands::undo::Undo),
38    Provider(commands::provider::Provider),
39    Review(commands::review::Review),
40    View(commands::view::View),
41    Sync(commands::sync::Sync),
42    Merge(commands::merge::Merge),
43    Repair(commands::repair::Repair),
44    Submit(commands::submit::Submit),
45    Config(commands::config::Config),
46    Completions(commands::completions::Completions),
47    Guide(commands::guide::Guide),
48    Setup(commands::setup::Setup),
49    Uninstall(commands::uninstall::Uninstall),
50    Upgrade(commands::upgrade::Upgrade),
51    Cleanup(commands::cleanup::Cleanup),
52    Credits(commands::credits::Credits),
53}
54
55#[derive(Debug, Clone, Copy, Eq, PartialEq)]
56pub enum UpdateRefsMode {
57    Config,
58    Enabled,
59    Disabled,
60}
61
62impl UpdateRefsMode {
63    pub fn from_flags(update_refs: bool, no_update_refs: bool) -> Self {
64        match (update_refs, no_update_refs) {
65            (true, false) => Self::Enabled,
66            (false, true) => Self::Disabled,
67            _ => Self::Config,
68        }
69    }
70}
71
72#[derive(Debug, Clone, Copy, Eq, PartialEq)]
73pub enum PushMode {
74    Config,
75    Enabled,
76    Disabled,
77}
78
79impl PushMode {
80    pub fn from_flags(push: bool, no_push: bool) -> Self {
81        match (push, no_push) {
82            (true, false) => Self::Enabled,
83            (false, true) => Self::Disabled,
84            _ => Self::Config,
85        }
86    }
87}