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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use clap::Parser;
use clap_complete::Shell;
use mit_commit_message_lints::{mit::lib::non_clean_behaviour::BehaviourOption, scope::Scope};
#[derive(Parser, Clone, Eq, PartialEq)]
#[clap(author, version, about)]
#[clap(bin_name = "git-mit-config")]
pub struct CliArgs {
#[clap(long, value_enum, value_parser)]
pub completion: Option<Shell>,
#[clap(subcommand)]
pub action: Option<Action>,
}
#[derive(clap::Subcommand, Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub enum Action {
/// Manage active lints
Lint {
#[clap(subcommand)]
action: Lint,
},
/// Manage mit configuration
Mit {
#[clap(subcommand)]
action: Mit,
},
/// Manage relates-to settings
RelatesTo {
#[clap(subcommand)]
action: RelatesTo,
},
}
#[derive(clap::Subcommand, Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub enum Lint {
/// Generate the config file for your current settings
Generate {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
},
/// List the available lints
Available {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
},
/// List the enabled lints
Enabled {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
},
/// Get the status of a lint
Status {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
#[clap()]
lints: Vec<mit_lint::Lint>,
},
/// Enable a lint
Enable {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
/// The lint to enable
#[clap()]
lints: Vec<mit_lint::Lint>,
},
/// Disable a lint
Disable {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
/// The lint to disable
#[clap()]
lints: Vec<mit_lint::Lint>,
},
}
#[derive(clap::Subcommand, Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub enum Mit {
/// Update or add an initial in the mit configuration
Set {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
/// Initial of the mit to update or add
#[clap()]
initials: String,
/// Name to use for the mit in format "Forename Surname"
#[clap()]
name: String,
/// Email to use for the mit
#[clap()]
email: String,
/// The signing key to use for this user
#[clap()]
signingkey: Option<String>,
},
/// Get the current behavior when the repository is mid-rebase or merge.
NonCleanBehaviour {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
},
/// Set the current behavior when the repository is mid-rebase or merge.
SetNonCleanBehaviour {
#[clap(long, value_enum, value_parser, default_value = "local")]
scope: Scope,
/// What to do for rebase, merge commits and similar
///
/// * 'add-to' will add the current author to the commit messages on rebase
/// * 'no-change' will leave the commit messages as is.
///
/// This also applies to merges and cherry-picks
#[clap(
index = 1,
env = "GIT_MIT_SET_NON_CLEAN_BEHAVIOUR",
default_value = "no-change"
)]
behaviour: BehaviourOption,
},
/// Generate a file version of available authors
Generate {
/// Path to a file where mit initials, emails and names can be found
#[clap(
short,
long,
env = "GIT_MIT_AUTHORS_CONFIG",
default_value = "$HOME/.config/git-mit/mit.toml"
)]
config: String,
/// Execute a command to generate the mit configuration, stdout will be
/// captured and used instead of the file, if both this and the file are
/// present, this takes precedence
#[clap(short, long, env = "GIT_MIT_AUTHORS_EXEC")]
exec: Option<String>,
},
/// List available authors
Available {
/// Path to a file where mit initials, emails and names can be found
#[clap(
short,
long,
env = "GIT_MIT_AUTHORS_CONFIG",
default_value = "$HOME/.config/git-mit/mit.toml"
)]
config: String,
/// Execute a command to generate the mit configuration, stdout will be
/// captured and used instead of the file, if both this and the file are
/// present, this takes precedence
#[clap(short, long, env = "GIT_MIT_AUTHORS_EXEC")]
exec: Option<String>,
},
/// Print example mit toml file
Example,
}
#[derive(clap::Subcommand, Ord, PartialOrd, Eq, PartialEq, Debug, Clone)]
pub enum RelatesTo {
/// Use a template for the relates-to trailer
Template {
#[clap(long, short, value_enum, value_parser, default_value = "local")]
scope: Scope,
/// A `TinyTemplate` template with a single value variable that will be
/// applied to the relates-to trailer
#[clap(
index = 1,
env = "GIT_MIT_RELATES_TO_TEMPLATE",
default_value = "{ value }"
)]
template: String,
},
}