DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Robin Jarry <rjarry@redhat.com>
Cc: dev@dpdk.org, bruce.richardson@intel.com,
	stephen@networkplumber.org, dmitry.kozliuk@gmail.com
Subject: Re: [PATCH] usertools/hugepages: show usage if no action specified
Date: Tue, 22 Nov 2022 16:22:18 +0100	[thread overview]
Message-ID: <4853392.0VBMTVartN@thomas> (raw)
In-Reply-To: <CO5YPY7EI8D3.3JDCW98A14KM6@paul>

07/11/2022 10:39, Robin Jarry:
> 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

It is a long message and not long enough to be accurate (long options are missing).
I would go with parser.error("no action specified")





  reply	other threads:[~2022-11-22 15:22 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
2022-11-22 15:22   ` Thomas Monjalon [this message]
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=4853392.0VBMTVartN@thomas \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=rjarry@redhat.com \
    --cc=stephen@networkplumber.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).