public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: Douglas Anderson <dianders@chromium.org>
Cc: sjg@chromium.org, amstan@chromium.org, mka@chromium.org,
	u-boot@lists.denx.de
Subject: Re: [PATCH 6/6] patman: Take project defaults into account for --help
Date: Thu, 30 Jun 2022 15:15:53 -0700	[thread overview]
Message-ID: <Yr4gmWakCgomCWun@google.com> (raw)
In-Reply-To: <20220630140742.6.I79b8a2fc40f11af2ba8108f0f8166c574ae5ab47@changeid>

On Thu, Jun 30, 2022 at 02:08:09PM -0700, Doug Anderson wrote:
> I'd like it so that when you do "patman send --help" and you're using
> Linux that it show it the proper defaults for Linux.
> 
> Signed-off-by: Douglas Anderson <dianders@chromium.org>
> ---
> 
>  tools/patman/main.py | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/patman/main.py b/tools/patman/main.py
> index 1ee44feab192..a0b0ad3bad9d 100755
> --- a/tools/patman/main.py
> +++ b/tools/patman/main.py
> @@ -109,14 +109,19 @@ status.add_argument('-d', '--dest-branch', type=str,
>  status.add_argument('-f', '--force', action=BooleanOptionalAction,
>                      help='Force overwriting an existing branch')
>  
> -# Parse options twice: first to get the project and second to handle
> -# defaults properly (which depends on project)
> +# Parse options several times:
> +# - first to get the project and second to handle defaults properly (which
> +#   depends on project).
> +# - second to handle --help after we've accounted for project defaults.

The previous bullet has a "second", and so does this one. Are those
different meanings, or are we counting wrong?

This might be a good place to say that this multiple passes on argparse
is very confusing to me. That's not to say that you need to explain it
for me, but just to say I'm probably not the best reviewer on this one.

Brian

> +# - finally after we have added an implicit command if necessary.
> +#
>  # Use parse_known_args() in case 'cmd' is omitted
> +argv = [arg for arg in sys.argv[1:] if arg not in ('-h', '--help')]
> +args, _ = parser.parse_known_args(argv)
>  argv = sys.argv[1:]
> -args, rest = parser.parse_known_args(argv)
>  if hasattr(args, 'project'):
>      settings.Setup(gitutil, parser, args.project, '')
> -    args, rest = parser.parse_known_args(argv)
> +args, rest = parser.parse_known_args(argv)
>  
>  # If we have a command, it is safe to parse all arguments
>  if args.cmd:
> -- 
> 2.37.0.rc0.161.g10f37bed90-goog
> 

  reply	other threads:[~2022-06-30 22:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30 21:08 [PATCH 0/6] patman: Small fixes plus remove --no-tree from checkpatch for linux Douglas Anderson
2022-06-30 21:08 ` [PATCH 1/6] patman: Fix updating argument defaults from settings Douglas Anderson
2022-06-30 21:08 ` [PATCH 2/6] patman: Fix implicit command inserting Douglas Anderson
2022-06-30 21:08 ` [PATCH 3/6] patman: Don't look at sys.argv when parsing settings Douglas Anderson
2022-06-30 21:08 ` [PATCH 4/6] patman: Make most bool arguments BooleanOptionalAction Douglas Anderson
2022-06-30 21:30   ` Brian Norris
2022-06-30 21:08 ` [PATCH 5/6] patman: By default don't pass "--no-tree" to checkpatch for linux Douglas Anderson
2022-06-30 21:08 ` [PATCH 6/6] patman: Take project defaults into account for --help Douglas Anderson
2022-06-30 22:15   ` Brian Norris [this message]
2022-06-30 22:18 ` [PATCH 0/6] patman: Small fixes plus remove --no-tree from checkpatch for linux Brian Norris

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=Yr4gmWakCgomCWun@google.com \
    --to=briannorris@chromium.org \
    --cc=amstan@chromium.org \
    --cc=dianders@chromium.org \
    --cc=mka@chromium.org \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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