mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge pull request #5301 from Will-Shanks/master
Correct title,name and synopsis in generated man pages for subcommands
This commit is contained in:
commit
040ff6a85d
3 changed files with 12 additions and 7 deletions
|
@ -27,7 +27,10 @@ impl Man {
|
||||||
/// Create a new manual page.
|
/// Create a new manual page.
|
||||||
pub fn new(mut cmd: clap::Command) -> Self {
|
pub fn new(mut cmd: clap::Command) -> Self {
|
||||||
cmd.build();
|
cmd.build();
|
||||||
let title = cmd.get_name().to_owned();
|
let title = cmd
|
||||||
|
.get_display_name()
|
||||||
|
.unwrap_or_else(|| cmd.get_name())
|
||||||
|
.to_owned();
|
||||||
let section = "1".to_owned();
|
let section = "1".to_owned();
|
||||||
let date = "".to_owned();
|
let date = "".to_owned();
|
||||||
let source = format!(
|
let source = format!(
|
||||||
|
|
|
@ -9,9 +9,10 @@ pub(crate) fn subcommand_heading(cmd: &clap::Command) -> &str {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn about(roff: &mut Roff, cmd: &clap::Command) {
|
pub(crate) fn about(roff: &mut Roff, cmd: &clap::Command) {
|
||||||
|
let name = cmd.get_display_name().unwrap_or_else(|| cmd.get_name());
|
||||||
let s = match cmd.get_about().or_else(|| cmd.get_long_about()) {
|
let s = match cmd.get_about().or_else(|| cmd.get_long_about()) {
|
||||||
Some(about) => format!("{} - {}", cmd.get_name(), about),
|
Some(about) => format!("{} - {}", name, about),
|
||||||
None => cmd.get_name().to_string(),
|
None => name.to_owned(),
|
||||||
};
|
};
|
||||||
roff.text([roman(s)]);
|
roff.text([roman(s)]);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +30,8 @@ pub(crate) fn description(roff: &mut Roff, cmd: &clap::Command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
|
pub(crate) fn synopsis(roff: &mut Roff, cmd: &clap::Command) {
|
||||||
let mut line = vec![bold(cmd.get_name()), roman(" ")];
|
let name = cmd.get_bin_name().unwrap_or_else(|| cmd.get_name());
|
||||||
|
let mut line = vec![bold(name), roman(" ")];
|
||||||
|
|
||||||
for opt in cmd.get_arguments().filter(|i| !i.is_hide_set()) {
|
for opt in cmd.get_arguments().filter(|i| !i.is_hide_set()) {
|
||||||
let (lhs, rhs) = option_markers(opt);
|
let (lhs, rhs) = option_markers(opt);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
.ie /n(.g .ds Aq /(aq
|
.ie /n(.g .ds Aq /(aq
|
||||||
.el .ds Aq '
|
.el .ds Aq '
|
||||||
.TH help 1 "help "
|
.TH my-app-help 1 "help "
|
||||||
.SH NAME
|
.SH NAME
|
||||||
help /- Print this message or the help of the given subcommand(s)
|
my/-app/-help /- Print this message or the help of the given subcommand(s)
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
/fBhelp/fR [/fIsubcommands/fR]
|
/fBmy/-app help/fR [/fIsubcommands/fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Print this message or the help of the given subcommand(s)
|
Print this message or the help of the given subcommand(s)
|
||||||
.SH SUBCOMMANDS
|
.SH SUBCOMMANDS
|
||||||
|
|
Loading…
Reference in a new issue