Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Jul 2019 03:48:48 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r350461 - head/sbin/nvmecontrol
Message-ID:  <201907310348.x6V3mmdS001774@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Jul 31 03:48:48 2019
New Revision: 350461
URL: https://svnweb.freebsd.org/changeset/base/350461

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

Modified:
  head/sbin/nvmecontrol/comnd.c

Modified: head/sbin/nvmecontrol/comnd.c
==============================================================================
--- head/sbin/nvmecontrol/comnd.c	Wed Jul 31 00:16:12 2019	(r350460)
+++ head/sbin/nvmecontrol/comnd.c	Wed Jul 31 03:48:48 2019	(r350461)
@@ -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?201907310348.x6V3mmdS001774>