Skip to main content

gitu/
cli.rs

1use std::path::PathBuf;
2
3use clap::{Parser, Subcommand};
4
5#[derive(Default, Debug, Parser)]
6#[command(name = "gitu")]
7#[command(flatten_help = true)]
8pub struct Args {
9    #[command(subcommand)]
10    pub command: Option<Commands>,
11
12    /// Send keys on startup (eg: `gitu -k ll`).
13    ///     It is possible to send:
14    ///     - single char-keys: a, b, c, ...
15    ///     - special keys: <backspace>, <enter>, <up>, <tab>, <delete>, <esc>, ...
16    ///     - modifiers: <ctrl+a>, <ctrl+shift+alt+a>, <shift+delete>
17    #[clap(short, long, verbatim_doc_comment)]
18    pub keys: Option<String>,
19
20    /// Print one frame and exit. Useful for debugging.
21    #[clap(long, action)]
22    pub print: bool,
23
24    /// Paging a patch piped to gitu, as git's pager, print it and exit if it
25    /// fits on one screen, as less's --quit-if-one-screen.
26    #[clap(long, action)]
27    pub quit_if_one_screen: bool,
28
29    /// Enable logging to 'gitu.log'
30    #[clap(long, action)]
31    pub log: bool,
32
33    /// Show external command output in the message area.
34    #[clap(long, action)]
35    pub debug: bool,
36
37    #[clap(long, action)]
38    /// Print version
39    pub version: bool,
40
41    /// Config file to use
42    #[clap(short, long)]
43    pub config: Option<PathBuf>,
44}
45
46#[derive(Debug, Subcommand)]
47pub enum Commands {
48    Show {
49        reference: String,
50    },
51    /// Interactively rebase onto <upstream>, editing the instruction list in Gitu.
52    Rebase {
53        upstream: String,
54    },
55    /// Edit a `git rebase -i` instruction list, for use as GIT_SEQUENCE_EDITOR:
56    ///     GIT_SEQUENCE_EDITOR='gitu sequence-editor' git rebase -i <upstream>
57    #[clap(verbatim_doc_comment)]
58    SequenceEditor {
59        file: PathBuf,
60    },
61    Blame {
62        file: String,
63        #[clap(short, long)]
64        rev: Option<String>,
65    },
66}