Don't render subcommand option section if there aren't any.

This commit is contained in:
Justus Winter 2024-01-12 13:04:34 +01:00
parent 01371366b5
commit 47f232f8e0
No known key found for this signature in database
GPG Key ID: 686F55B4AB2B3386

View File

@ -399,7 +399,11 @@ impl Command {
man.text_with_period(&self.description());
let main_opts = builder.maincmd.has_options();
let cmd_opts = self.has_options() && self != &builder.maincmd;
let cmd_opts = self.has_options() && self != &builder.maincmd
&& self.get_options().iter()
.filter(|o| ! builder.maincmd.get_options().contains(o))
.next().is_some();
if main_opts || cmd_opts {
man.section("OPTIONS");
}
@ -473,7 +477,11 @@ impl Command {
man.text_with_period(&self.description());
let main_opts = builder.maincmd.has_options();
let self_opts = self.has_options();
let self_opts = self.has_options()
&& self.get_options().iter()
.filter(|o| ! builder.maincmd.get_options().contains(o))
.next().is_some();
if main_opts || self_opts {
man.section("OPTIONS");
}