Skip to content

Commit

Permalink
simplify the utility function
Browse files Browse the repository at this point in the history
Co-authored-by: Benno van den Berg <[email protected]>
  • Loading branch information
2 people authored and ConnorGray committed Jun 15, 2024
1 parent 8da57cc commit b1df50a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,11 @@ fn write_arg_markdown(buffer: &mut String, arg: &clap::Arg) -> fmt::Result {
// to get the display name if it exists, otherwise get the bin name if it exists, otherwise
// get the package name.
fn get_canonical_name(command: &clap::Command) -> String {
return match command.get_display_name() {
Some(bin_name) => bin_name.to_owned(),
None => command
.get_bin_name()
.unwrap_or_else(|| command.get_name())
.to_owned(),
};
command
.get_display_name()
.or_else(|| command.get_bin_name())
.map(|name| name.to_owned())
.unwrap_or_else(|| command.get_name().to_owned())
}

/// Indents non-empty lines. The output always ends with a newline.
Expand Down

0 comments on commit b1df50a

Please sign in to comment.