[virt-tools-list] [virt-manager] [PATCH 1/2] cli: Replace '_' from cli_arg_name with '-' before saving to parsernames

Cole Robinson crobinso at redhat.com
Sun Jan 6 23:38:36 UTC 2019


On 12/24/2018 03:35 AM, Lin Ma wrote:
> The patch makes --qemu-commandline subprops completion works.
> 
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>   virtinst/cli.py | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/virtinst/cli.py b/virtinst/cli.py
> index 21586b19..3ba81861 100644
> --- a/virtinst/cli.py
> +++ b/virtinst/cli.py
> @@ -494,7 +494,8 @@ def autocomplete(parser):
>   
>       import argcomplete
>   
> -    parsernames = ["--" + pclass.cli_arg_name for pclass in VIRT_PARSERS]
> +    parsernames = ["--" + pclass.cli_arg_name.replace("_", "-")
> +                   for pclass in VIRT_PARSERS]
>       # pylint: disable=protected-access
>       for action in parser._actions:
>           for opt in action.option_strings:
> 

Good catch. But looks like there's some other incorrect cli_arg_name 
usages as well. Can you add something like

@classmethod
def cli_flag_name(cls):
     return "--" + cls.cli_arg_name.replace("_", "-")

And convert the other incorrect cli_arg_name users to it. For example 
the underscore printed here:

$ ./virt-xml --qemu-commandline=help
--qemu_commandline options:
   args
   clearxml
   env


Thanks,
Cole




More information about the virt-tools-list mailing list