Skip to content

Commit

Permalink
Merge branch 'concise-help-text' into 'master'
Browse files Browse the repository at this point in the history
Reformat help output

See merge request mkjeldsen/commitmsgfmt!71
  • Loading branch information
commonquail committed Oct 22, 2023
2 parents 0b773ed + 328c2f7 commit a209fe7
Showing 1 changed file with 22 additions and 38 deletions.
60 changes: 22 additions & 38 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@ macro_rules! str_version {
// Use dynamic binary name in help output
macro_rules! str_help_common {
() => {
concat!(
str_version!(),
'\n',
r#"Formats commit messages better than fmt(1) and Vim
USAGE:
{} [OPTIONS]
r#"Usage: {} [OPTIONS]
Formats commit messages better than fmt(1) and Vim
FLAGS:"#
)
-h, --help Prints help information
-V, --version Prints version information"#
};
}

Expand All @@ -35,11 +30,7 @@ macro_rules! str_help_short {
concat!(
str_help_common!(),
r#"
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-w, --width <WIDTH> The message body max paragraph width. Default: 72."#
-w, --width <NUM> The message body max paragraph width. Default: 72."#
)
};
}
Expand All @@ -49,28 +40,21 @@ macro_rules! str_help_long {
concat!(
str_help_common!(),
r#"
-h, --help
Prints help information
-V, --version
Prints version information
OPTIONS:
-w, --width <WIDTH>
The max width, in graphemes, of regular paragraphs. Text will be wrapped at
the last space up to this limit, or at the limit, and list item continuations
indented. Default: 72.
-w, --width <NUM>
The max width, in graphemes, of regular paragraphs. Text will be
wrapped at the last space up to this limit, or at the limit, and
list item continuations indented. Default: 72.
Some text is exempt from wrapping:
- The subject line ignores this setting and is instead broken down into a
subject line and a paragraph after 90 graphemes. The subject line works best
across different formats when forced into a single line but this harsh
behaviour necessitates a laxer limit on its length to avoid rejecting too
many valid subjects.
- The subject line ignores this setting and is instead broken down
into a subject line and a paragraph after 90 graphemes. The
subject line works best across different formats when forced into
a single line but this harsh behaviour necessitates a laxer limit
on its length to avoid rejecting too many valid subjects.
- Text indented at least 4 spaces or 1 tab, and trailers, are printed unchanged."#
- Text indented at least 4 spaces or 1 tab; trailers; and block
quotes are printed unchanged."#
)
};
}
Expand Down Expand Up @@ -738,9 +722,9 @@ b o d y
let out = String::from_utf8_lossy(&output.stdout);
let out_ci = out.to_lowercase();
assert!(out_ci.contains("usage:"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(out.contains("exempt"));
}

Expand All @@ -755,9 +739,9 @@ b o d y
let out = String::from_utf8_lossy(&output.stdout);
let out_ci = out.to_lowercase();
assert!(out_ci.contains("usage:"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(out.contains("\n -h, --help"));
assert!(out.contains("\n -V, --version"));
assert!(out.contains("\n -w, --width"));
assert!(!out.contains("exempt"));
}

Expand Down

0 comments on commit a209fe7

Please sign in to comment.