Skip to content

Commit

Permalink
Fix padding on #[long] args in help text. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Apr 13, 2023
1 parent 815b77d commit 8f9c346
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions onlyargs_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,13 @@ fn to_help(view: ArgView, max_width: usize) -> String {
let pad = " ".repeat(max_width + LONG_PAD);
let help = view.doc.join(&format!("\n{pad}"));

let width = max_width - name.len();
if let Some(ch) = view.short {
let width = max_width - SHORT_PAD - name.len();
let width = width - SHORT_PAD;

format!(" -{ch} --{name}{ty:<width$} {help}\n")
} else {
format!(" --{name}{ty:<max_width$} {help}\n")
format!(" --{name}{ty:<width$} {help}\n")
}
}

Expand Down

0 comments on commit 8f9c346

Please sign in to comment.