Skip to content

Commit

Permalink
Fixed warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
Magicolo committed Feb 24, 2024
1 parent b44d44e commit 8d1bdcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() -> Result<(), Error> {
command: Command,
}

let parser = Builder::new()
let parser = Parser::builder()
.case(Case::Kebab { upper: false })
.option(|option| option.name("d").name("debug").help("Debug mode.").default(false))
.option(|option| option.name("y").name("yes").swizzle().default(false))
Expand Down
24 changes: 8 additions & 16 deletions src/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
value: &str,
prefix: impl Format,
suffix: impl Format,
pre: impl Format,
post: impl Format,
wrap: impl Format,
cursor: &mut usize,
has: &mut bool,
) -> Result<usize, fmt::Error> {
Expand All @@ -178,10 +177,8 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
}
_ => {
width += self.write_line(())?;
*cursor = 0;
width += self.write(&pre)?;
*cursor += self.indentation()?;
width += self.write(&post)?;
*cursor = self.indentation()?;
width += self.write(&wrap)?;
}
}

Expand All @@ -193,10 +190,8 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {

if *cursor + word.len() > self.style.width() {
width += self.write_line(())?;
*cursor = 0;
width += self.write(&pre)?;
*cursor += self.indentation()?;
width += self.write(&post)?;
*cursor = self.indentation()?;
width += self.write(&wrap)?;
}
*cursor += self.write(word)?;
}
Expand All @@ -220,7 +215,7 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
if !value.chars().all(char::is_whitespace) {
count += self.write_line(())?;
count += self.indentation()?;
count += self.wrap(value, &prefix, "", "", &line, &mut 0, &mut false)?;
count += self.wrap(value, &prefix, "", &line, &mut 0, &mut false)?;
}
}
}
Expand All @@ -241,13 +236,13 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
let mut width = 0;
for meta in visible(metas) {
if let Meta::Summary(value) = meta {
width += self.wrap(value, &prefix, &suffix, "", "", &mut cursor, &mut has)?;
width += self.wrap(value, &prefix, &suffix, "", &mut cursor, &mut has)?;
}
}
if width == 0 {
for meta in visible(metas) {
if let Meta::Help(value) = meta {
width += self.wrap(value, &prefix, &suffix, "", "", &mut cursor, &mut has)?;
width += self.wrap(value, &prefix, &suffix, "", &mut cursor, &mut has)?;
}
}
}
Expand Down Expand Up @@ -330,7 +325,6 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
helper.style.begin(Item::Help),
helper.style.end(Item::Help),
"",
"",
&mut 0,
&mut false,
)?;
Expand All @@ -346,7 +340,6 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
helper.style.begin(Item::Note),
helper.style.end(Item::Note),
"",
"",
&mut 0,
&mut false,
)?;
Expand Down Expand Up @@ -411,7 +404,6 @@ impl<'a, S: Style + ?Sized + 'a> Helper<'a, S> {
helper.style.begin(Item::Tag),
helper.style.end(Item::Tag),
"",
"",
&mut width,
&mut false,
)?;
Expand Down

0 comments on commit 8d1bdcb

Please sign in to comment.