Skip to content

Commit

Permalink
Merge pull request #5893 from 8LWXpg/patch-2
Browse files Browse the repository at this point in the history
fix(complete): Check if help string is empty
  • Loading branch information
epage authored Jan 27, 2025
2 parents 7e54542 + 6ffc88f commit cf15d48
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions clap_complete/src/aot/shells/powershell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ fn escape_string(string: &str) -> String {
}

fn escape_help<T: ToString>(help: Option<&StyledStr>, data: T) -> String {
match help {
Some(help) => escape_string(&help.to_string().replace('\n', " ")),
_ => data.to_string(),
if let Some(help) = help {
let help_str = help.to_string();
if !help_str.is_empty() {
return escape_string(&help_str.replace('\n', " "));
}
}
data.to_string()
}

fn generate_inner(p: &Command, previous_command_name: &str) -> String {
Expand Down

0 comments on commit cf15d48

Please sign in to comment.