Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(help): Update auto-next-line to use new padding #4463

Merged
merged 2 commits into from Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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