1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Equivalent to init + install
II {
/// hook name, currently only supports commit-msg and pre-commit
hook: String,
#[arg(short = 'f', long = "force")]
force: bool,
},
/// Initialize configuration file in the repository root
Init {
/// hook name, currently only supports commit-msg
hook: String,
#[arg(short = 'f', long = "force")]
force: bool,
},
/// Install git hook script into the .git/hooks directory
Install {
/// hook name, currently only supports commit-msg
hook: String,
#[arg(short = 'f', long = "force")]
force: bool,
},
/// Uninstall git hook script from the .git/hooks directory
Uninstall {
/// hook name, currently only supports commit-msg
hook: String,
},
/// Run the specified git hook script
Run {
/// hook name, currently only supports commit-msg
#[command(subcommand)]
hook: RunCmd,
},
}
#[derive(Debug, Clone, Subcommand)]
pub enum RunCmd {
/// Validate commit message
// #[command(name = "commit-msg")]
CommitMsg {
/// Path to commit message file
#[arg(long)]
msg: PathBuf,
/// Path to rule file
#[arg(long)]
rule: PathBuf,
},
/// Run pre-commit hook
// #[command(name = "pre-commit")]
PreCommit {
/// Path to rule file
#[arg(long)]
rule: PathBuf,
},
}