From: "Robin Jarry" <rjarry@redhat.com>
To: "Thomas Monjalon" <thomas@monjalon.net>, <dev@dpdk.org>
Cc: <bruce.richardson@intel.com>, <stephen@networkplumber.org>,
<dmitry.kozliuk@gmail.com>
Subject: Re: [PATCH] usertools/hugepages: show usage if no action specified
Date: Mon, 07 Nov 2022 10:39:59 +0100 [thread overview]
Message-ID: <CO5YPY7EI8D3.3JDCW98A14KM6@paul> (raw)
In-Reply-To: <20221104113018.4069058-1-thomas@monjalon.net>
Thomas Monjalon, Nov 04, 2022 at 12:30:
> Previously, the script was doing nothing if no argument was provided.
>
> If neither show, mount/unmount, clear/reserve are specified,
> it is assumed that the user does not know how to use the script.
> So the usage is printed and an error code is used in exit.
> The user will understand something is wrong,
> and can recall the script with the option -h to get more information.
>
> Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
> ---
> usertools/dpdk-hugepages.py | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/usertools/dpdk-hugepages.py b/usertools/dpdk-hugepages.py
> index a22d504d3a..823cfcf185 100755
> --- a/usertools/dpdk-hugepages.py
> +++ b/usertools/dpdk-hugepages.py
> @@ -272,6 +272,10 @@ def main():
> args.reserve = args.setup
> args.mount = True
>
> + if not (args.show or args.mount or args.unmount or args.clear or args.reserve):
> + parser.print_usage()
> + sys.exit(1)
Hi Thomas,
I believe you can do:
parser.error("at least one of -s/-c/-m/-u/-r/--setup is required")
and omit sys.exit(1).
$ ~/dev/dpdk/usertools/dpdk-hugepages.py
usage: dpdk-hugepages.py [-h] [--show] [--clear] [--mount] [--unmount] [--node NODE] [--pagesize SIZE] [--reserve SIZE] [--setup SIZE]
dpdk-hugepages.py: error: at least one of -s/-c/-m/-u/-r/--setup is required
next prev parent reply other threads:[~2022-11-07 9:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-04 11:30 Thomas Monjalon
2022-11-07 9:39 ` Robin Jarry [this message]
2022-11-22 15:22 ` Thomas Monjalon
2022-11-22 15:32 ` [PATCH v2] " Thomas Monjalon
2022-11-22 15:38 ` David Marchand
2022-11-22 15:42 ` Thomas Monjalon
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=CO5YPY7EI8D3.3JDCW98A14KM6@paul \
--to=rjarry@redhat.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
/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).