mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
fix(help): Make next-line help less sensitive to tab changes
This commit is contained in:
parent
d3fc37b678
commit
876da97d1c
1 changed files with 7 additions and 3 deletions
|
@ -547,11 +547,13 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
|||
// Is help on next line, if so then indent
|
||||
if next_line_help {
|
||||
debug!("Help::help: Next Line...{:?}", next_line_help);
|
||||
self.none(format!("\n{}{}{}", TAB, TAB, TAB));
|
||||
self.none("\n");
|
||||
self.none(TAB);
|
||||
self.none(NEXT_LINE_INDENT);
|
||||
}
|
||||
|
||||
let trailing_indent = if next_line_help {
|
||||
TAB_WIDTH * 3
|
||||
TAB.len() + NEXT_LINE_INDENT.len()
|
||||
} else if let Some(true) = arg.map(|a| a.is_positional()) {
|
||||
longest + TAB_WIDTH * 2
|
||||
} else {
|
||||
|
@ -560,7 +562,7 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
|||
let trailing_indent = self.get_spaces(trailing_indent);
|
||||
|
||||
let spaces = if next_line_help {
|
||||
TAB_WIDTH * 3
|
||||
TAB.len() + NEXT_LINE_INDENT.len()
|
||||
} else {
|
||||
longest + TAB_WIDTH * 3
|
||||
};
|
||||
|
@ -932,6 +934,8 @@ impl<'cmd, 'writer> Help<'cmd, 'writer> {
|
|||
}
|
||||
}
|
||||
|
||||
const NEXT_LINE_INDENT: &str = " ";
|
||||
|
||||
type ArgSortKey = fn(arg: &Arg) -> (usize, String);
|
||||
|
||||
fn positional_sort_key(arg: &Arg) -> (usize, String) {
|
||||
|
|
Loading…
Reference in a new issue