yocto-check-layer: make argument parsing unambiguous

Submitted by Ross Burton on Dec. 10, 2020, 4:20 p.m. | Patch ID: 178809

Details

Message ID 20201210162023.3239592-1-ross.burton@arm.com
State Master Next
Commit aea3ff48d27b102e76d29ee19a970d36160ed07e
Headers show

Commit Message

Ross Burton Dec. 10, 2020, 4:20 p.m.
Currently the argument parser uses nargs=+ for both the layers
(positional arguments) and machines/dependencies/addition layers
(optional arguments).  This means it's impossible to determine what is
meant by:

$ yocto-check-layer --machines a b c

Is this machines=(a,b) and layers=(c), or machines=(a) and layers=(b,c)?
Or even machines=(a,b,c) and layers=(), which results in a parse failure
as the layers are mandatory?

The workaround is to re-order the arguments to an unambiguous form:

$ yocto-check-layer b c --machines a

However this means the user needs to know the problem and how to work
around it.  Instead, change the parser to require an explicit --layers
argument:

$ yocto-check-layer --machines a --layers b c

Also improve the other arguments by adding clearer metavars and short
options.

[ YOCTO #14148 ]

Signed-off-by: Ross Burton <ross.burton@arm.com>

---
 scripts/yocto-check-layer | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#145450): https://lists.openembedded.org/g/openembedded-core/message/145450
Mute This Topic: https://lists.openembedded.org/mt/78857660/1003190
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-

Patch hide | download patch | download mbox

diff --git a/scripts/yocto-check-layer b/scripts/yocto-check-layer
index b7c83c8b54..7c7d6013d8 100755
--- a/scripts/yocto-check-layer
+++ b/scripts/yocto-check-layer
@@ -45,15 +45,15 @@  def main():
     parser = argparse.ArgumentParser(
             description="Yocto Project layer checking tool",
             add_help=False)
-    parser.add_argument('layers', metavar='LAYER_DIR', nargs='+',
-            help='Layer to check')
+    parser.add_argument('-l', '--layers', metavar='LAYER_DIR', nargs='+',
+            required=True, help='Layers to check')
     parser.add_argument('-o', '--output-log',
             help='File to output log (optional)', action='store')
-    parser.add_argument('--dependency', nargs="+",
+    parser.add_argument('-p', '--dependency', nargs="+", metavar='LAYER_DIR',
             help='Layers to process for dependencies', action='store')
-    parser.add_argument('--machines', nargs="+",
+    parser.add_argument('-m', '--machines', nargs="+", metavar='MACHINE',
             help='List of MACHINEs to be used during testing', action='store')
-    parser.add_argument('--additional-layers', nargs="+",
+    parser.add_argument('-a', '--additional-layers', nargs="+", metavar='LAYER_DIR',
             help='List of additional layers to add during testing', action='store')
     group = parser.add_mutually_exclusive_group()
     group.add_argument('--with-software-layer-signature-check', action='store_true', dest='test_software_layer_signatures',

Comments

Richard Purdie Dec. 14, 2020, 1:30 p.m.
On Thu, 2020-12-10 at 16:20 +0000, Ross Burton wrote:
> Currently the argument parser uses nargs=+ for both the layers

> (positional arguments) and machines/dependencies/addition layers

> (optional arguments).  This means it's impossible to determine what is

> meant by:

> 

> $ yocto-check-layer --machines a b c

> 

> Is this machines=(a,b) and layers=(c), or machines=(a) and layers=(b,c)?

> Or even machines=(a,b,c) and layers=(), which results in a parse failure

> as the layers are mandatory?

> 

> The workaround is to re-order the arguments to an unambiguous form:

> 

> $ yocto-check-layer b c --machines a

> 

> However this means the user needs to know the problem and how to work

> around it.  Instead, change the parser to require an explicit --layers

> argument:

> 

> $ yocto-check-layer --machines a --layers b c

> 

> Also improve the other arguments by adding clearer metavars and short

> options.

> 

> [ YOCTO #14148 ]

> 

> Signed-off-by: Ross Burton <ross.burton@arm.com>

> ---

>  scripts/yocto-check-layer | 10 +++++-----

>  1 file changed, 5 insertions(+), 5 deletions(-)


https://autobuilder.yoctoproject.org/typhoon/#/builders/39/builds/2825

Do we need to update the way we're calling it on the autobuilder?

Cheers,

Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#145558): https://lists.openembedded.org/g/openembedded-core/message/145558
Mute This Topic: https://lists.openembedded.org/mt/78857660/1003190
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-
Ross Burton Dec. 14, 2020, 5:30 p.m.
On Mon, 14 Dec 2020 at 13:31, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:

> https://autobuilder.yoctoproject.org/typhoon/#/builders/39/builds/2825

>

> Do we need to update the way we're calling it on the autobuilder?


Yes.  Sorry, forgot this was on the autobuilder.  Patch incoming.

Ross
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#145604): https://lists.openembedded.org/g/openembedded-core/message/145604
Mute This Topic: https://lists.openembedded.org/mt/78857660/1003190
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-