mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-23 06:32:57 +00:00
btrfs-progs: help: print multiple syntax schemas on separate lines
The help string for some commands could be split to more lines for clarity, eg. as is now in the receive command. The 'btrfs help' listing should indent all the lines properly, similar the command specific help with "usage:'. The syntax of the first help string line is to separate all command usage schemas by "\n". Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
eebdf02321
commit
c56d61883c
24
help.c
24
help.c
@ -128,12 +128,32 @@ static int do_usage_one_command(const char * const *usagestr,
|
|||||||
unsigned int flags, FILE *outf)
|
unsigned int flags, FILE *outf)
|
||||||
{
|
{
|
||||||
int pad = 4;
|
int pad = 4;
|
||||||
|
const char *prefix = "usage: ";
|
||||||
|
const char *pad_listing = " ";
|
||||||
|
|
||||||
if (!usagestr || !*usagestr)
|
if (!usagestr || !*usagestr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fprintf(outf, "%s%s", (flags & USAGE_LISTING) ? " " : "usage: ",
|
if (flags & USAGE_LISTING)
|
||||||
*usagestr++);
|
prefix = pad_listing;
|
||||||
|
|
||||||
|
fputs(prefix, outf);
|
||||||
|
if (strchr(*usagestr, '\n') == NULL) {
|
||||||
|
fputs(*usagestr, outf);
|
||||||
|
} else {
|
||||||
|
const char *c = *usagestr;
|
||||||
|
const char *nprefix = " ";
|
||||||
|
|
||||||
|
if (flags & USAGE_LISTING)
|
||||||
|
nprefix = pad_listing;
|
||||||
|
|
||||||
|
for (c = *usagestr; *c; c++) {
|
||||||
|
fputc(*c, outf);
|
||||||
|
if (*c == '\n')
|
||||||
|
fputs(nprefix, outf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
usagestr++;
|
||||||
|
|
||||||
/* a short one-line description (mandatory) */
|
/* a short one-line description (mandatory) */
|
||||||
if ((flags & USAGE_SHORT) == 0)
|
if ((flags & USAGE_SHORT) == 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user