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    Credits(commands::credits::Credits),
51}
52
53#[derive(Debug, Clone, Copy, Eq, PartialEq)]
54pub enum UpdateRefsMode {
55    Config,
56    Enabled,
57    Disabled,
58}
59
60impl UpdateRefsMode {
61    pub fn from_flags(update_refs: bool, no_update_refs: bool) -> Self {
62        match (update_refs, no_update_refs) {
63            (true, false) => Self::Enabled,
64            (false, true) => Self::Disabled,
65            _ => Self::Config,
66        }
67    }
68}
69
70#[derive(Debug, Clone, Copy, Eq, PartialEq)]
71pub enum PushMode {
72    Config,
73    Enabled,
74    Disabled,
75}
76
77impl PushMode {
78    pub fn from_flags(push: bool, no_push: bool) -> Self {
79        match (push, no_push) {
80            (true, false) => Self::Enabled,
81            (false, true) => Self::Disabled,
82            _ => Self::Config,
83        }
84    }
85}