For any given subcommand allow to specify multi-line usage (separated by \n).
Submitted by: Mel Flynn
This commit is contained in:
parent
d134008aa0
commit
963feac4e9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196877
@ -98,11 +98,21 @@ usage_command(struct g_command *cmd, const char *prefix)
|
|||||||
struct g_option *opt;
|
struct g_option *opt;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
|
|
||||||
if (cmd->gc_usage != NULL) {
|
if (cmd->gc_usage != NULL) {
|
||||||
fprintf(stderr, " %s\n", cmd->gc_usage);
|
char *pos, *ptr, *sptr;
|
||||||
|
|
||||||
|
sptr = ptr = strdup(cmd->gc_usage);
|
||||||
|
while ((pos = strsep(&ptr, "\n")) != NULL) {
|
||||||
|
if (*pos == '\0')
|
||||||
|
continue;
|
||||||
|
fprintf(stderr, "%s %s %s %s\n", prefix, comm,
|
||||||
|
cmd->gc_name, pos);
|
||||||
|
}
|
||||||
|
free(sptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name);
|
||||||
if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0)
|
if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0)
|
||||||
fprintf(stderr, " [-v]");
|
fprintf(stderr, " [-v]");
|
||||||
for (i = 0; ; i++) {
|
for (i = 0; ; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user