@@ -22,8 +22,8 @@ macro_rules! str_help_common {
22
22
r#"Usage: {} [OPTIONS]
23
23
Formats commit messages better than fmt(1) and Vim
24
24
25
- -h, --help Prints help information
26
- -V, --version Prints version information"#
25
+ -h, --help Prints help information
26
+ -V, --version Prints version information"#
27
27
} ;
28
28
}
29
29
@@ -32,7 +32,8 @@ macro_rules! str_help_short {
32
32
concat!(
33
33
str_help_common!( ) ,
34
34
r#"
35
- -w, --width <NUM> The message body max paragraph width. Default: 72."#
35
+ -w, --width <NUM> The message body max paragraph width. Default: 72.
36
+ -c, --comment-string <STR> The string to detect a comment. Default taken from git config."#
36
37
)
37
38
} ;
38
39
}
@@ -56,7 +57,12 @@ macro_rules! str_help_long {
56
57
on its length to avoid rejecting too many valid subjects.
57
58
58
59
- Text indented at least 4 spaces or 1 tab; trailers; and block
59
- quotes are printed unchanged."#
60
+ quotes are printed unchanged.
61
+
62
+ -c, --comment-string <STR>
63
+ The string used to detect a comment. By default it queries git config
64
+ for the value and defaults to `#`. Supply this to use a different value
65
+ such as `JJ` for files that are to be commited in a jujutsu repository."#
60
66
)
61
67
} ;
62
68
}
@@ -139,6 +145,7 @@ enum CliArgument<'a> {
139
145
140
146
enum ConfigArgument < ' a > {
141
147
Width ( Option < & ' a str > ) ,
148
+ CommentString ( Option < & ' a str > ) ,
142
149
}
143
150
144
151
#[ derive( Debug , Eq , PartialEq ) ]
@@ -150,9 +157,11 @@ pub struct Config {
150
157
impl Config {
151
158
fn new ( args : Vec < ConfigArgument < ' _ > > ) -> CliResult < ' _ , Config > {
152
159
let mut width: Option < & str > = None ;
160
+ let mut comment_string: Option < & str > = None ;
153
161
for arg in args {
154
162
match arg {
155
163
ConfigArgument :: Width ( s) => width = s,
164
+ ConfigArgument :: CommentString ( s) => comment_string = s,
156
165
}
157
166
}
158
167
@@ -165,9 +174,13 @@ impl Config {
165
174
return Err ( CliError :: ArgWidthOutOfBounds ( width) ) ;
166
175
}
167
176
177
+ let comment_string = match comment_string {
178
+ None => parse_git_config_commentchar ( git_config_commentchar ( ) ) ,
179
+ Some ( comment) => comment. to_string ( ) ,
180
+ } ;
168
181
let cfg = Config {
169
182
width : width as usize ,
170
- comment_string : parse_git_config_commentchar ( git_config_commentchar ( ) ) ,
183
+ comment_string,
171
184
} ;
172
185
173
186
Ok ( cfg)
@@ -249,6 +262,10 @@ fn parse_args(args: &'_ [String]) -> Vec<CliArgument<'_>> {
249
262
let parsed_arg = match longopt_key {
250
263
"--help" => CliArgument :: HelpLong ,
251
264
"--version" => CliArgument :: Version ,
265
+ "--comment-string" => {
266
+ let p = longopt_value ( ) ;
267
+ CliArgument :: Config ( ConfigArgument :: CommentString ( p) )
268
+ }
252
269
"--width" => {
253
270
let w = longopt_value ( ) ;
254
271
CliArgument :: Config ( ConfigArgument :: Width ( w) )
0 commit comments