Skip to content

Commit

Permalink
Merge pull request #4463 from epage/help
Browse files Browse the repository at this point in the history
fix(help): Update auto-next-line to use new padding
  • Loading branch information
epage committed Nov 7, 2022
2 parents bc457b1 + dfe9e73 commit eaa6bfe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
10 changes: 7 additions & 3 deletions src/output/help_template.rs
Expand Up @@ -689,7 +689,11 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
// force_next_line
let h = arg.get_help().unwrap_or_default();
let h_w = h.display_width() + display_width(spec_vals);
let taken = longest + 12;
let taken = if arg.is_positional() {
longest + TAB_WIDTH * 2
} else {
longest + TAB_WIDTH * 2 + 4 // See `fn short` for the 4
};
self.term_w >= taken
&& (taken as f32 / self.term_w as f32) > 0.40
&& h_w > (self.term_w - taken)
Expand Down Expand Up @@ -925,7 +929,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
// force_next_line
let h = cmd.get_about().unwrap_or_default();
let h_w = h.display_width() + display_width(spec_vals);
let taken = longest + 12;
let taken = longest + TAB_WIDTH * 2;
self.term_w >= taken
&& (taken as f32 / self.term_w as f32) > 0.40
&& h_w > (self.term_w - taken)
Expand All @@ -939,7 +943,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
self.none(TAB);
self.writer.extend(sc_str.into_iter());
if !next_line_help {
self.spaces(width.max(longest + TAB_WIDTH) - width);
self.spaces(longest + TAB_WIDTH - width);
}
}
}
Expand Down
19 changes: 8 additions & 11 deletions tests/builder/help.rs
Expand Up @@ -355,17 +355,14 @@ fn wrapped_help() {
Usage: test [OPTIONS]
Options:
-a, --all
Also do versioning for private crates (will not be
published)
--exact
Specify inter dependency version numbers exactly with `=`
--no-git-commit
Do not commit version changes
--no-git-push
Do not push generated commit and tags to git remote
-h, --help
Print help information
-a, --all Also do versioning for private crates (will
not be published)
--exact Specify inter dependency version numbers
exactly with `=`
--no-git-commit Do not commit version changes
--no-git-push Do not push generated commit and tags to git
remote
-h, --help Print help information
";
let cmd = Command::new("test")
.term_width(67)
Expand Down

0 comments on commit eaa6bfe

Please sign in to comment.