Fix usage printing for nested subcommands.
Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc. MFC after: 2 weeks
This commit is contained in:
parent
520482f4aa
commit
628d03169e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=350461
@ -49,11 +49,23 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
static struct cmd top;
|
static struct cmd top;
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_tree(const struct cmd *f)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (f->parent != NULL)
|
||||||
|
print_tree(f->parent);
|
||||||
|
if (f->name != NULL)
|
||||||
|
fprintf(stderr, " %s", f->name);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_usage(const struct cmd *f)
|
print_usage(const struct cmd *f)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stderr, " %s %-15s - %s\n", getprogname(), f->name, f->descr);
|
fprintf(stderr, " %s", getprogname());
|
||||||
|
print_tree(f->parent);
|
||||||
|
fprintf(stderr, " %-15s - %s\n", f->name, f->descr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -120,7 +132,8 @@ arg_help(int argc __unused, char * const *argv, const struct cmd *f)
|
|||||||
// XXX walk up the cmd list...
|
// XXX walk up the cmd list...
|
||||||
if (argv[optind])
|
if (argv[optind])
|
||||||
fprintf(stderr, "Unknown argument: %s\n", argv[optind]);
|
fprintf(stderr, "Unknown argument: %s\n", argv[optind]);
|
||||||
fprintf(stderr, "Usage:\n %s %s", getprogname(), argv[0]);
|
fprintf(stderr, "Usage:\n %s", getprogname());
|
||||||
|
print_tree(f);
|
||||||
if (opts)
|
if (opts)
|
||||||
fprintf(stderr, " <args>");
|
fprintf(stderr, " <args>");
|
||||||
if (args) {
|
if (args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user