summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-06-08 14:07:39 -0500
committerDavid Teigland <teigland@redhat.com>2021-06-08 14:07:39 -0500
commitdf27392c8c9ec5d1efd92c2214805471473f2a06 (patch)
tree27b2460f8cc14b829f98432c0b6cde5b16073a95
parentca930bd936de2e7d4a83fa64add800baf6cfd116 (diff)
downloadlvm2-df27392c8c9ec5d1efd92c2214805471473f2a06.tar.gz
man/help: fix common option listing
-rw-r--r--tools/command.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/command.c b/tools/command.c
index 1de739aaa..7205969e1 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2146,6 +2146,7 @@ void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
{
int oo, opt_enum;
+ int found_common_command = 0;
/*
* when there's more than one variant, options that
@@ -2155,6 +2156,18 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf(" Common options for command:");
/* print options with short opts */
@@ -2213,7 +2226,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
printf(" ]");
}
- printf(".P\n");
+ printf("\n\n");
}
void print_usage_notes(struct command_name *cname)
@@ -2994,6 +3007,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
{
struct command_name *cname;
int i, sep, oo, opt_enum;
+ int found_common_command = 0;
if (!(cname = _find_command_name(cmd->name)))
return;
@@ -3001,6 +3015,18 @@ static void _print_man_usage_common_cmd(struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf("Common options for command:\n");
printf(".\n");