DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/2] eal: add help option
Date: Thu, 12 Feb 2015 17:47:57 +0100	[thread overview]
Message-ID: <1423759677-32152-3-git-send-email-thomas.monjalon@6wind.com> (raw)
In-Reply-To: <1423759677-32152-1-git-send-email-thomas.monjalon@6wind.com>

Help is printed with -h or --help.

Help is also printed for an unknown option.
This was broken since the rework of options.

Fixes: 489a9d6c9f77 ("merge bsd and linux common options parsing")

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
Acked-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/bsdapp/eal/eal.c            | 7 ++++++-
 lib/librte_eal/common/eal_common_options.c | 3 +++
 lib/librte_eal/common/eal_options.h        | 2 ++
 lib/librte_eal/linuxapp/eal/eal.c          | 8 +++++++-
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 69f3c03..ca2f445 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -326,8 +326,10 @@ eal_parse_args(int argc, char **argv)
 		int ret;
 
 		/* getopt is not happy, stop right now */
-		if (opt == '?')
+		if (opt == '?') {
+			eal_usage(prgname);
 			return -1;
+		}
 
 		ret = eal_parse_common_option(opt, optarg, &internal_config);
 		/* common parser is not happy */
@@ -340,6 +342,9 @@ eal_parse_args(int argc, char **argv)
 			continue;
 
 		switch (opt) {
+		case 'h':
+			eal_usage(prgname);
+			exit(EXIT_SUCCESS);
 		default:
 			if (opt < OPT_LONG_MIN_NUM && isprint(opt)) {
 				RTE_LOG(ERR, EAL, "Option %c is not supported "
diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 3dda237..4314e4e 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -57,6 +57,7 @@ eal_short_options[] =
 	"b:" /* pci-blacklist */
 	"c:" /* coremask */
 	"d:" /* driver */
+	"h"  /* help */
 	"l:" /* corelist */
 	"m:" /* memory size */
 	"n:" /* memory channels */
@@ -70,6 +71,7 @@ eal_long_options[] = {
 	{OPT_BASE_VIRTADDR,     1, NULL, OPT_BASE_VIRTADDR_NUM    },
 	{OPT_CREATE_UIO_DEV,    1, NULL, OPT_CREATE_UIO_DEV_NUM   },
 	{OPT_FILE_PREFIX,       1, NULL, OPT_FILE_PREFIX_NUM      },
+	{OPT_HELP,              0, NULL, OPT_HELP_NUM             },
 	{OPT_HUGE_DIR,          1, NULL, OPT_HUGE_DIR_NUM         },
 	{OPT_LOG_LEVEL,         1, NULL, OPT_LOG_LEVEL_NUM        },
 	{OPT_MASTER_LCORE,      1, NULL, OPT_MASTER_LCORE_NUM     },
@@ -605,6 +607,7 @@ eal_common_usage(void)
 	       "  --"OPT_SYSLOG"            Set syslog facility\n"
 	       "  --"OPT_LOG_LEVEL"         Set default log level\n"
 	       "  -v                  Display version information on startup\n"
+	       "  -h, --help          This help\n"
 	       "\nEAL options for DEBUG use only:\n"
 	       "  --"OPT_NO_HUGE"           Use malloc instead of hugetlbfs\n"
 	       "  --"OPT_NO_PCI"            Disable PCI\n"
diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h
index fe1c85d..d199a00 100644
--- a/lib/librte_eal/common/eal_options.h
+++ b/lib/librte_eal/common/eal_options.h
@@ -35,6 +35,8 @@
 
 enum {
 	/* long options mapped to a short option */
+#define OPT_HELP              "help"
+	OPT_HELP_NUM            = 'h',
 #define OPT_PCI_BLACKLIST     "pci-blacklist"
 	OPT_PCI_BLACKLIST_NUM   = 'b',
 #define OPT_PCI_WHITELIST     "pci-whitelist"
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index e3955e7..d8c0628 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -520,8 +520,10 @@ eal_parse_args(int argc, char **argv)
 		int ret;
 
 		/* getopt is not happy, stop right now */
-		if (opt == '?')
+		if (opt == '?') {
+			eal_usage(prgname);
 			return -1;
+		}
 
 		ret = eal_parse_common_option(opt, optarg, &internal_config);
 		/* common parser is not happy */
@@ -534,6 +536,10 @@ eal_parse_args(int argc, char **argv)
 			continue;
 
 		switch (opt) {
+		case 'h':
+			eal_usage(prgname);
+			exit(EXIT_SUCCESS);
+
 		/* force loading of external driver */
 		case 'd':
 			solib = malloc(sizeof(*solib));
-- 
2.2.2

  parent reply	other threads:[~2015-02-12 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 18:07 [dpdk-dev] [PATCH 0/2] " Thomas Monjalon
2015-01-29 18:07 ` [dpdk-dev] [PATCH 1/2] eal: sort and align options lists Thomas Monjalon
2015-01-29 18:07 ` [dpdk-dev] [PATCH 2/2] eal: add help option Thomas Monjalon
2015-02-02 17:44 ` [dpdk-dev] [PATCH v2 0/2] " Thomas Monjalon
2015-02-02 17:44   ` [dpdk-dev] [PATCH v2 1/2] eal: sort and align options lists Thomas Monjalon
2015-02-03  6:26     ` David Marchand
2015-02-03  8:27       ` Thomas Monjalon
     [not found]   ` <1422899093-20207-3-git-send-email-thomas.monjalon@6wind.com>
2015-02-03  6:33     ` [dpdk-dev] [PATCH v2 2/2] eal: add help option David Marchand
2015-02-03  8:20       ` Thomas Monjalon
2015-02-03  9:07         ` David Marchand
2015-02-12 16:47   ` [dpdk-dev] [PATCH v3 0/2] " Thomas Monjalon
2015-02-12 16:47     ` [dpdk-dev] [PATCH v3 1/2] eal: sort and align options lists Thomas Monjalon
2015-02-12 16:47     ` Thomas Monjalon [this message]
2015-02-13 10:50     ` [dpdk-dev] [PATCH v3 0/2] help option David Marchand
2015-02-24 11:09       ` Thomas Monjalon
2015-02-13 12:57     ` Neil Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423759677-32152-3-git-send-email-thomas.monjalon@6wind.com \
    --to=thomas.monjalon@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).