Skip to content

Commit

Permalink
refactor(help): Collapse useless function
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jun 15, 2022
1 parent 17d9757 commit c443aa0
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions src/output/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,18 @@ impl<'help, 'cmd, 'writer> Help<'help, 'cmd, 'writer> {
) -> io::Result<()> {
let spec_vals = &self.spec_vals(arg);

self.write_arg_inner(arg, spec_vals, next_line_help, longest)?;
self.short(arg)?;
self.long(arg)?;
self.val(arg)?;
self.align_to_about(arg, next_line_help, longest)?;

let about = if self.use_long {
arg.long_help.or(arg.help).unwrap_or("")
} else {
arg.help.or(arg.long_help).unwrap_or("")
};

self.help(Some(arg), about, spec_vals, next_line_help, longest)?;

if !last_arg {
self.none("\n")?;
Expand Down Expand Up @@ -532,29 +543,6 @@ impl<'help, 'cmd, 'writer> Help<'help, 'cmd, 'writer> {
Ok(())
}

/// Writes help for an argument to the wrapped stream.
fn write_arg_inner(
&mut self,
arg: &Arg<'help>,
spec_vals: &str,
next_line_help: bool,
longest: usize,
) -> io::Result<()> {
self.short(arg)?;
self.long(arg)?;
self.val(arg)?;
self.align_to_about(arg, next_line_help, longest)?;

let about = if self.use_long {
arg.long_help.or(arg.help).unwrap_or("")
} else {
arg.help.or(arg.long_help).unwrap_or("")
};

self.help(Some(arg), about, spec_vals, next_line_help, longest)?;
Ok(())
}

/// Will use next line help on writing args.
fn will_args_wrap(&self, args: &[&Arg<'help>], longest: usize) -> bool {
args.iter()
Expand Down

0 comments on commit c443aa0

Please sign in to comment.