Subject: Re: [PATCH net-next v1 2/2] tools/net/ynl: Add multi message support to ynl

From: Jakub Kicinski <[email-masked]>
Date: Thu, 28 Mar 2024 17:57:29 -0700

On Wed, 27 Mar 2024 18:17:00 +0000 Donald Hunter wrote:
> -    parser = argparse.ArgumentParser(description='YNL CLI sample')
> +    description = """
> +    YNL CLI utility - a general purpose netlink utility that uses YNL specs

YNL specs is intentional or should have been YAML? :)

> +    to drive protocol encoding and decoding.
> +    """
> +    epilog = """
> +    The --multi option can be repeated to include several operations
> +    in the same netlink payload.
> +    """
> +
> +    parser = argparse.ArgumentParser(description=description,
> +                                     epilog=epilog)
>      parser.add_argument('--spec', dest='spec', type=str, required=True)
>      parser.add_argument('--schema', dest='schema', type=str)
>      parser.add_argument('--no-schema', action='store_true')
>      parser.add_argument('--json', dest='json_text', type=str)
> -    parser.add_argument('--do', dest='do', type=str)
> -    parser.add_argument('--dump', dest='dump', type=str)
> +    parser.add_argument('--do', dest='do', metavar='OPERATION', type=str)
> +    parser.add_argument('--dump', dest='dump', metavar='OPERATION', type=str)
>      parser.add_argument('--sleep', dest='sleep', type=int)
>      parser.add_argument('--subscribe', dest='ntf', type=str)
>      parser.add_argument('--replace', dest='flags', action='append_const',
> @@ -40,6 +50,8 @@ def main():
>      parser.add_argument('--output-json', action='store_true')
>      parser.add_argument('--dbg-small-recv', default=0, const=4000,
>                          action='store', nargs='?', type=int)
> +    parser.add_argument('--multi', dest='multi', nargs=2, action='append',
> +                        metavar=('OPERATION', 'JSON_TEXT'), type=str)

We'd only support multiple "do" requests, I wonder if we should somehow
call this out. Is --multi-do unnecessary extra typing?

Code itself looks pretty good!