All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Chris Laplante" <chris.laplante@agilent.com>
To: <bitbake-devel@lists.openembedded.org>
Cc: Chris Laplante <chris.laplante@agilent.com>
Subject: [PATCH v3 08/10] main: fix parsing of intermixed arguments
Date: Sun, 8 Nov 2020 17:10:57 -0500	[thread overview]
Message-ID: <20201108221059.16854-9-chris.laplante@agilent.com> (raw)
In-Reply-To: <20201108221059.16854-1-chris.laplante@agilent.com>

use parse_known_args instead of parse_args. Otherwise, argparse
incorreclty interprets (for example) 'bitbake -S none world'.

Signed-off-by: Chris Laplante <chris.laplante@agilent.com>
---
 lib/bb/main.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lib/bb/main.py b/lib/bb/main.py
index f8a19bc3..9ce931d6 100755
--- a/lib/bb/main.py
+++ b/lib/bb/main.py
@@ -132,7 +132,6 @@ def create_bitbake_parser():
     It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
     will provide the layer, BBFILES and other configuration information.
     """, add_help=False)
-    parser.add_argument("targets", nargs="*")
 
     # List options that the user is most likely to use first
     frequent_group = parser.add_argument_group("frequently used")
@@ -304,7 +303,7 @@ def create_bitbake_parser():
 class BitBakeConfigParameters(cookerdata.ConfigParameters):
     def parseCommandLine(self, argv=None):
         parser = create_bitbake_parser()
-        args = parser.parse_args(argv or sys.argv)
+        args, targets = parser.parse_known_args(argv or sys.argv)
 
         if args.quiet and args.verbose:
             parser.error("options --quiet and --verbose are mutually exclusive")
@@ -336,7 +335,7 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
         else:
             args.xmlrpcinterface = (None, 0)
 
-        return args, args.targets[1:]
+        return args, targets[1:]
 
 
 def bitbake_main(configParams, configuration):
-- 
2.17.1


  parent reply	other threads:[~2020-11-08 22:12 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-08 22:10 [PATCH v3 00/10] optparse => argparse Chris Laplante
2020-11-08 22:10 ` [PATCH v3 01/10] cookerdata: tweak to avoid mutable default argument Chris Laplante
2020-11-08 22:10 ` [PATCH v3 02/10] tests/arg_parser: add stub for testing arg parsing Chris Laplante
2020-11-08 22:10 ` [PATCH v3 03/10] tests/arg_parser: add test for 'bitbake -S none world' Chris Laplante
2020-11-08 22:10 ` [PATCH v3 04/10] main: migrate from optparse to argparse Chris Laplante
2020-11-08 22:10 ` [PATCH v3 05/10] main: group --help options to make them easier to read Chris Laplante
2020-11-08 22:10 ` [PATCH v3 06/10] main: rename list_extension_modules => load_extension_modules to clarify its function Chris Laplante
2020-11-08 22:10 ` [PATCH v3 07/10] tests/arg_parser: add test for lazy loading of bb.ui modules Chris Laplante
2020-11-08 22:10 ` Chris Laplante [this message]
2020-11-08 22:10 ` [PATCH v3 09/10] tinfoil: use knotty module itself as default 'ui' arg to keep up with changes in setup_bitbake Chris Laplante
2020-11-08 22:10 ` [PATCH v3 10/10] tests/arg_parser: add test for default TinfoilConfigParameters 'ui' Chris Laplante
2020-11-10 21:33 ` [bitbake-devel] [PATCH v3 00/10] optparse => argparse Richard Purdie
2020-11-10 21:36   ` Chris Laplante
2020-11-10 21:38 ` Richard Purdie
2020-11-10 21:40   ` Chris Laplante
2020-11-18 16:37   ` Chris Laplante
2020-11-18 16:44     ` Richard Purdie
2020-11-18 17:07       ` Chris Laplante
2020-11-18 17:24         ` Richard Purdie
2020-11-18 21:01           ` Chris Laplante
2020-11-20 11:17             ` Richard Purdie
     [not found]       ` <1648A9226B93C86E.28066@lists.openembedded.org>
2020-11-18 17:08         ` Chris Laplante

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=20201108221059.16854-9-chris.laplante@agilent.com \
    --to=chris.laplante@agilent.com \
    --cc=bitbake-devel@lists.openembedded.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.