Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Aug 2019 18:58:51 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r350942 - stable/12/sbin/nvmecontrol
Message-ID:  <201908121858.x7CIwp3m065682@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Mon Aug 12 18:58:51 2019
New Revision: 350942
URL: https://svnweb.freebsd.org/changeset/base/350942

Log:
  MFC r350461: Fix usage printing for nested subcommands.
  
  Instead of `nvmecontrol create` should be `nvmecontrol ns create`, etc.

Modified:
  stable/12/sbin/nvmecontrol/comnd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/nvmecontrol/comnd.c
==============================================================================
--- stable/12/sbin/nvmecontrol/comnd.c	Mon Aug 12 18:58:20 2019	(r350941)
+++ stable/12/sbin/nvmecontrol/comnd.c	Mon Aug 12 18:58:51 2019	(r350942)
@@ -50,10 +50,22 @@ __FBSDID("$FreeBSD$");
 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
 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
@@ -120,7 +132,8 @@ arg_help(int argc __unused, char * const *argv, const 
 	// XXX walk up the cmd list...
 	if (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)
 		fprintf(stderr, " <args>");
 	if (args) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201908121858.x7CIwp3m065682>