imp(subcommands): "SUBCOMMANDS" label affected by subcommand placeholder

This commit is contained in:
Kitlith 2020-06-27 14:17:47 -07:00
parent e5c66e58a6
commit 6d083f5653

View file

@ -750,7 +750,18 @@ impl<'b, 'c, 'd, 'w> Help<'b, 'c, 'd, 'w> {
if !first {
self.none("\n\n")?;
}
self.warning("SUBCOMMANDS:\n")?;
let subcommand_string = self.parser.app.subcommand_placeholder.unwrap_or("SUBCOMMAND");
self.warning(subcommand_string)?;
// TODO: simply appending an 's' doesn't work for every string.
let pluralizer = if subcommand_string.chars().last().unwrap_or('D').is_lowercase() {
"s"
} else {
"S"
};
self.warning(pluralizer)?;
self.warning(":\n")?;
self.write_subcommands(&self.parser.app)?;
}