Re: [PATCH 4/6] patman: Make most bool arguments BooleanOptionalAction

Brian Norris
2022-06-30T21:30:51Z

On Thu, Jun 30, 2022 at 02:08:07PM -0700, Doug Anderson wrote:
> For boolean arguments it's convenient to be able to specify both the
> argument and its opposite on the command line. This is especially
> convenient because you can change the default via the settings file
> and being able express the opposite can be the only way to override
> things.
>
> Luckily python handles this well--we just need to specify things with
> BooleanOptionalAction. We'll do that for all options except
> "full-help" (where it feels silly). This uglifies the help text a
> little bit but does give maximum flexibility.
>
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
>
> tools/patman/main.py | 52 +++++++++++++++++++++++---------------------
> 1 file changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/tools/patman/main.py b/tools/patman/main.py
> index 336f4e439aa9..9684300c022c 100755
> --- a/tools/patman/main.py
> +++ b/tools/patman/main.py

> -send.add_argument('-t', '--ignore-bad-tags', action='store_true',
> +send.add_argument('-t', '--ignore-bad-tags', action=BooleanOptionalAction,
> default=False,
> help='Ignore bad tags / aliases (default=warn)')

I know you mentioned --help ugliness, but this one ends up looking like:

(default=warn) (default: False)

Perhaps we should drop the baked-in "(default=warn)" text?

Otherwise:

Reviewed-by: Brian Norris <briannorris@chromium.org>
Tested-by: Brian Norris <briannorris@chromium.org>