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-08 16:52:26 -0600
commite00ebdc934312e5368c50f90805510b9b6ad52d4 (patch)
tree5ec3ad7f77b3b55a05287b7777362a42424bf05f
parent60d26a4e42276ea94122dfc4c238692610365cc3 (diff)
downloadlvm2-e00ebdc934312e5368c50f90805510b9b6ad52d4.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 40025c169..555eb2d0b 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: