@@ -22,8 +22,8 @@ macro_rules! str_help_common {
2222 r#"Usage: {} [OPTIONS]
2323Formats commit messages better than fmt(1) and Vim
2424
25- -h, --help Prints help information
26- -V, --version Prints version information"#
25+ -h, --help Prints help information
26+ -V, --version Prints version information"#
2727 } ;
2828}
2929
@@ -32,7 +32,8 @@ macro_rules! str_help_short {
3232 concat!(
3333 str_help_common!( ) ,
3434 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."#
3637 )
3738 } ;
3839}
@@ -56,7 +57,12 @@ macro_rules! str_help_long {
5657 on its length to avoid rejecting too many valid subjects.
5758
5859 - 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."#
6066 )
6167 } ;
6268}
@@ -139,6 +145,7 @@ enum CliArgument<'a> {
139145
140146enum ConfigArgument < ' a > {
141147 Width ( Option < & ' a str > ) ,
148+ CommentString ( Option < & ' a str > ) ,
142149}
143150
144151#[ derive( Debug , Eq , PartialEq ) ]
@@ -150,9 +157,11 @@ pub struct Config {
150157impl Config {
151158 fn new ( args : Vec < ConfigArgument < ' _ > > ) -> CliResult < ' _ , Config > {
152159 let mut width: Option < & str > = None ;
160+ let mut comment_string: Option < & str > = None ;
153161 for arg in args {
154162 match arg {
155163 ConfigArgument :: Width ( s) => width = s,
164+ ConfigArgument :: CommentString ( s) => comment_string = s,
156165 }
157166 }
158167
@@ -165,9 +174,13 @@ impl Config {
165174 return Err ( CliError :: ArgWidthOutOfBounds ( width) ) ;
166175 }
167176
177+ let comment_string = match comment_string {
178+ None => parse_git_config_commentchar ( git_config_commentchar ( ) ) ,
179+ Some ( comment) => comment. to_string ( ) ,
180+ } ;
168181 let cfg = Config {
169182 width : width as usize ,
170- comment_string : parse_git_config_commentchar ( git_config_commentchar ( ) ) ,
183+ comment_string,
171184 } ;
172185
173186 Ok ( cfg)
@@ -249,6 +262,10 @@ fn parse_args(args: &'_ [String]) -> Vec<CliArgument<'_>> {
249262 let parsed_arg = match longopt_key {
250263 "--help" => CliArgument :: HelpLong ,
251264 "--version" => CliArgument :: Version ,
265+ "--comment-string" => {
266+ let p = longopt_value ( ) ;
267+ CliArgument :: Config ( ConfigArgument :: CommentString ( p) )
268+ }
252269 "--width" => {
253270 let w = longopt_value ( ) ;
254271 CliArgument :: Config ( ConfigArgument :: Width ( w) )
0 commit comments