Skip to content

Commit c178b5d

Browse files
committed
refactor: replace the brittle string replacement
1 parent d2b6169 commit c178b5d

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

src/usage_md.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,13 @@ fn write_option_description(out: &mut String, arg: &Arg) {
198198
}
199199

200200
fn get_help_text(arg: &Arg) -> Cow<'static, str> {
201-
let help = match (arg.get_help(), arg.get_long_help()) {
202-
(None, None) => return Cow::Borrowed(""),
203-
(Some(help), None) | (_, Some(help)) => help.to_string(),
204-
};
205-
let help = if help.contains("see a summary with") && help.contains("help") {
206-
"Print help".to_string()
207-
} else {
208-
help
209-
};
210-
Cow::Owned(help)
201+
if !arg.is_positional() && arg.get_id() == "help" {
202+
return Cow::Borrowed("Print help");
203+
}
204+
match (arg.get_help(), arg.get_long_help()) {
205+
(None, None) => Cow::Borrowed(""),
206+
(Some(help), None) | (_, Some(help)) => Cow::Owned(help.to_string()),
207+
}
211208
}
212209

213210
fn render_examples_section<'a>(out: &mut String, lines: impl Iterator<Item = &'a str>) {

0 commit comments

Comments
 (0)