[libvirt PATCH v2 2/6] ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter

Erik Skultety posted 6 patches 4 years, 10 months ago
There is a newer version of this series
[libvirt PATCH v2 2/6] ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter
Posted by Erik Skultety 4 years, 10 months ago
This help formatter class reports the defaults we use for options
taking an argument.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 ci/helper | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ci/helper b/ci/helper
index 73a3f729da..8f34f4b59d 100755
--- a/ci/helper
+++ b/ci/helper
@@ -79,6 +79,7 @@ class Parser:
             "build",
             help="run a build in a container",
             parents=[containerparser, mesonparser],
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
         buildparser.set_defaults(func=Application.action_build)
 
@@ -87,6 +88,7 @@ class Parser:
             "test",
             help="run a build in a container (including tests)",
             parents=[containerparser, mesonparser],
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
         testparser.set_defaults(func=Application.action_test)
 
@@ -95,6 +97,7 @@ class Parser:
             "shell",
             help="start a shell in a container",
             parents=[containerparser],
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
         shellparser.set_defaults(func=Application.action_shell)
 
@@ -102,6 +105,7 @@ class Parser:
         listimagesparser = subparsers.add_parser(
             "list-images",
             help="list known container images",
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
         listimagesparser.set_defaults(func=Application.action_list_images)
 
@@ -110,6 +114,7 @@ class Parser:
             "refresh",
             help="refresh data generated with lcitool",
             parents=[lcitoolparser],
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         )
         refreshparser.set_defaults(func=Application.action_refresh)
 
-- 
2.29.2

Re: [libvirt PATCH v2 2/6] ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter
Posted by Andrea Bolognani 4 years, 10 months ago
On Tue, 2021-03-16 at 18:32 +0100, Erik Skultety wrote:
> This help formatter class reports the defaults we use for options
> taking an argument.
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  ci/helper | 5 +++++
>  1 file changed, 5 insertions(+)

It's a shame that we have to repeat this for every single action
instead of being able to set it for the top-level parser and have
subparser inherit that. Oh well.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

Re: [libvirt PATCH v2 2/6] ci: helper: Use the ArgumentDefaultsHelpFormatter help formatter
Posted by Erik Skultety 4 years, 10 months ago
On Wed, Mar 17, 2021 at 11:52:22AM +0100, Andrea Bolognani wrote:
> On Tue, 2021-03-16 at 18:32 +0100, Erik Skultety wrote:
> > This help formatter class reports the defaults we use for options
> > taking an argument.
> > 
> > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > ---
> >  ci/helper | 5 +++++
> >  1 file changed, 5 insertions(+)
> 
> It's a shame that we have to repeat this for every single action
> instead of being able to set it for the top-level parser and have
> subparser inherit that. Oh well.

Yep, I was sad as well when I found out.

> 
> Reviewed-by: Andrea Bolognani <abologna@redhat.com>

Thanks,
Erik