summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-02-08 16:52:26 -0600
committerDavid Teigland <teigland@redhat.com>2017-02-09 12:10:25 -0600
commit5e7d9d4b925b74c58743d20efb3eca79d11dba3c (patch)
tree96d46a925f57b41d47e5d5b60be8f3647d3525f7
parente43203f64c2b5eb2c045d2a1b10887cb971a05bf (diff)
downloadlvm2-5e7d9d4b925b74c58743d20efb3eca79d11dba3c.tar.gz
man: break long lines that would wrap
When all the required command line elements would go beyond 80 chars and wrap to a new line, insert a line break and indent, and continue the required elements on a second line.
-rw-r--r--tools/command.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/command.c b/tools/command.c
index 3b889ae42..79824d56c 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1856,6 +1856,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
struct command_name *cname;
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
int i, sep, ro, rp, oo, op, opt_enum;
+ int need_ro_indent_end = 0;
if (!(cname = find_command_name(cmd->name)))
return;
@@ -1910,7 +1911,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
- sep = 1;
+ sep++;
}
/* print required options without a short opt */
@@ -1934,7 +1935,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
- sep = 1;
+ sep++;
}
printf(" )\n");
@@ -1968,7 +1969,16 @@ void print_man_usage(char *lvmname, struct command *cmd)
*/
if (cmd->ro_count) {
+ sep = 0;
+
for (ro = 0; ro < cmd->ro_count; ro++) {
+
+ /* avoid long line wrapping */
+ if ((cmd->ro_count > 2) && (sep == 2)) {
+ printf("\n.RS 5\n");
+ need_ro_indent_end = 1;
+ }
+
opt_enum = cmd->required_opt_args[ro].opt;
if (opt_names[opt_enum].short_opt) {
@@ -1983,6 +1993,8 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf(" ");
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
+
+ sep++;
}
}
@@ -2000,6 +2012,9 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf("\n");
}
+ if (need_ro_indent_end)
+ printf(".RE\n");
+
printf(".br\n");
oo_count: