~rjarry/dlrepo

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH dlrepo] cli: new no-print-url option

Details
Message ID
<20241211105734.4148431-1-julien.floret@6wind.com>
DKIM signature
pass
Download raw message
Patch: +28 -6
The --print-url/--no-print-url options allow enabling or disabling the
printing of the target URL to stderr. Printing is on by default.
"--no-print-url" is useful in scripts, where we want actual errors to
pop in stderr, but not "URL:" lines.

Suggested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Julien Floret <julien.floret@6wind.com>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 dlrepo-cli | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/dlrepo-cli b/dlrepo-cli
index 1396ba80993d..cd117b7e01cb 100755
--- a/dlrepo-cli
+++ b/dlrepo-cli
@@ -80,6 +80,22 @@ def main():
        More verbose output.
        """,
    )
    parser.add_argument(
        "--print-url",
        action="store_true",
        help="""
        Print the target URL.
        """,
    )
    parser.add_argument(
        "--no-print-url",
        dest="print_url",
        action="store_false",
        help="""
        Do not print the target URL.
        """,
    )
    parser.set_defaults(print_url=True)
    sub = parser.add_subparsers(title="sub-command help", metavar="SUB_COMMAND")
    sub.required = True

@@ -221,7 +237,8 @@ def get_info(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        for k, v in data["job"].items():
            if isinstance(v, list):
                v = " ".join(v)
@@ -307,7 +324,8 @@ def get_description(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        description = data.get("tag", {}).get("description")
        if description is not None:
            print(description)
@@ -340,7 +358,8 @@ def branches(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.verbose:
            out = []
            branch_len = 0
@@ -396,7 +415,8 @@ def tags(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        for tag in data["branch"]["tags"]:
            print(tag["name"])

@@ -426,7 +446,8 @@ def jobs(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        for job in data["tag"]["jobs"]:
            print(job["name"])

@@ -446,7 +467,8 @@ def status(args):
    if args.raw_json:
        print(json.dumps(data, indent=2))
    else:
        print("URL: %s" % client.make_url(url), file=sys.stderr)
        if args.print_url:
            print("URL: %s" % client.make_url(url), file=sys.stderr)
        print("released=%s" % data["tag"]["released"])
        print("stable=%s" % data["tag"]["stable"])
        print("locked=%s" % data["tag"]["locked"])
-- 
2.39.2

[dlrepo/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D68TGWY8Z22Z.HYSGV6J6Y5DY@fra01>
In-Reply-To
<20241211105734.4148431-1-julien.floret@6wind.com> (view parent)
DKIM signature
missing
Download raw message
dlrepo/patches/.build.yml: SUCCESS in 43s

[cli: new no-print-url option][0] from [Julien Floret][1]

[0]: https://lists.sr.ht/~rjarry/dlrepo/patches/56373
[1]: julien.floret@6wind.com

✓ #1387465 SUCCESS dlrepo/patches/.build.yml https://builds.sr.ht/~rjarry/job/1387465
Details
Message ID
<D68THS7H8IHW.162S537FWOQO6@ringo>
In-Reply-To
<20241211105734.4148431-1-julien.floret@6wind.com> (view parent)
DKIM signature
pass
Download raw message
Julien Floret, Dec 11, 2024 at 11:57:
> The --print-url/--no-print-url options allow enabling or disabling the
> printing of the target URL to stderr. Printing is on by default.
> "--no-print-url" is useful in scripts, where we want actual errors to
> pop in stderr, but not "URL:" lines.
>
> Suggested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> Signed-off-by: Julien Floret <julien.floret@6wind.com>
> Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> ---
>  dlrepo-cli | 34 ++++++++++++++++++++++++++++------
>  1 file changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/dlrepo-cli b/dlrepo-cli
> index 1396ba80993d..cd117b7e01cb 100755
> --- a/dlrepo-cli
> +++ b/dlrepo-cli
> @@ -80,6 +80,22 @@ def main():
>          More verbose output.
>          """,
>      )
> +    parser.add_argument(
> +        "--print-url",
> +        action="store_true",
> +        help="""
> +        Print the target URL.
> +        """,
> +    )
> +    parser.add_argument(
> +        "--no-print-url",
> +        dest="print_url",
> +        action="store_false",
> +        help="""
> +        Do not print the target URL.
> +        """,
> +    )
> +    parser.set_defaults(print_url=True)

Since there is a default value, why do you need to add two flags to
disable/enable URL printing?

>      sub = parser.add_subparsers(title="sub-command help", metavar="SUB_COMMAND")
>      sub.required = True
>  
> @@ -221,7 +237,8 @@ def get_info(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          for k, v in data["job"].items():
>              if isinstance(v, list):
>                  v = " ".join(v)
> @@ -307,7 +324,8 @@ def get_description(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          description = data.get("tag", {}).get("description")
>          if description is not None:
>              print(description)
> @@ -340,7 +358,8 @@ def branches(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          if args.verbose:
>              out = []
>              branch_len = 0
> @@ -396,7 +415,8 @@ def tags(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          for tag in data["branch"]["tags"]:
>              print(tag["name"])
>  
> @@ -426,7 +446,8 @@ def jobs(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          for job in data["tag"]["jobs"]:
>              print(job["name"])
>  
> @@ -446,7 +467,8 @@ def status(args):
>      if args.raw_json:
>          print(json.dumps(data, indent=2))
>      else:
> -        print("URL: %s" % client.make_url(url), file=sys.stderr)
> +        if args.print_url:
> +            print("URL: %s" % client.make_url(url), file=sys.stderr)
>          print("released=%s" % data["tag"]["released"])
>          print("stable=%s" % data["tag"]["stable"])
>          print("locked=%s" % data["tag"]["locked"])
> -- 
> 2.39.2
Details
Message ID
<CAHfJR7h8R2rztmE8JKBCAGjUh96OPVAY--6WZjH72Omexrq8cQ@mail.gmail.com>
In-Reply-To
<D68THS7H8IHW.162S537FWOQO6@ringo> (view parent)
DKIM signature
pass
Download raw message
Le mer. 11 déc. 2024 à 11:59, Robin Jarry <robin@jarry.cc> a écrit :
>
> Julien Floret, Dec 11, 2024 at 11:57:
> > The --print-url/--no-print-url options allow enabling or disabling the
> > printing of the target URL to stderr. Printing is on by default.
> > "--no-print-url" is useful in scripts, where we want actual errors to
> > pop in stderr, but not "URL:" lines.
> >
> > Suggested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> > Signed-off-by: Julien Floret <julien.floret@6wind.com>
> > Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
> > ---
> >  dlrepo-cli | 34 ++++++++++++++++++++++++++++------
> >  1 file changed, 28 insertions(+), 6 deletions(-)
> >
> > diff --git a/dlrepo-cli b/dlrepo-cli
> > index 1396ba80993d..cd117b7e01cb 100755
> > --- a/dlrepo-cli
> > +++ b/dlrepo-cli
> > @@ -80,6 +80,22 @@ def main():
> >          More verbose output.
> >          """,
> >      )
> > +    parser.add_argument(
> > +        "--print-url",
> > +        action="store_true",
> > +        help="""
> > +        Print the target URL.
> > +        """,
> > +    )
> > +    parser.add_argument(
> > +        "--no-print-url",
> > +        dest="print_url",
> > +        action="store_false",
> > +        help="""
> > +        Do not print the target URL.
> > +        """,
> > +    )
> > +    parser.set_defaults(print_url=True)
>
> Since there is a default value, why do you need to add two flags to
> disable/enable URL printing?

Indeed, only one option is needed. v2 is on its way :)
Thanks for the review!
Reply to thread Export thread (mbox)