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 /// Read a patch on stdin and browse it, for use as git's pager:
25 /// GIT_PAGER='gitu --pager' git show
26 #[clap(long, action, verbatim_doc_comment)]
27 pub pager: bool,
28
29 /// With --pager, print what fits on one screen and exit, as less's --quit-if-one-screen.
30 #[clap(long, action, requires = "pager")]
31 pub quit_if_one_screen: bool,
32
33 /// Enable logging to 'gitu.log'
34 #[clap(long, action)]
35 pub log: bool,
36
37 /// Show external command output in the message area.
38 #[clap(long, action)]
39 pub debug: bool,
40
41 #[clap(long, action)]
42 /// Print version
43 pub version: bool,
44
45 /// Config file to use
46 #[clap(short, long)]
47 pub config: Option<PathBuf>,
48}
49
50#[derive(Debug, Subcommand)]
51pub enum Commands {
52 Show {
53 reference: String,
54 },
55 /// Interactively rebase onto <upstream>, editing the instruction list in Gitu.
56 Rebase {
57 upstream: String,
58 },
59 /// Edit a `git rebase -i` instruction list, for use as GIT_SEQUENCE_EDITOR:
60 /// GIT_SEQUENCE_EDITOR='gitu sequence-editor' git rebase -i <upstream>
61 #[clap(verbatim_doc_comment)]
62 SequenceEditor {
63 file: PathBuf,
64 },
65 Blame {
66 file: String,
67 #[clap(short, long)]
68 rev: Option<String>,
69 },
70}