Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,27 @@ fn write_help_markdown(

let title = match options.title {
Some(ref title) => title.to_owned(),
None => format!("Command-Line Help for `{title_name}`"),
None => {
// Try to use the command's about text as the title
if let Some(about) = command.get_about() {
about.to_string()
} else {
format!("Command-Line Help for `{title_name}`")
}
},
};
writeln!(buffer, "# {title}\n",).unwrap();

writeln!(
buffer,
"This document contains the help content for the `{}` command-line program.\n",
title_name
).unwrap();
// Use the command's long_about or about text as the introduction, if available
if let Some(long_about) = command.get_long_about() {
writeln!(buffer, "{}\n", long_about).unwrap();
} else {
writeln!(
buffer,
"This document contains the help content for the `{}` command-line program.\n",
title_name
).unwrap();
}

//----------------------------------
// Write the table of contents
Expand Down