[virt-tools-list] [virt-manager] [RFC PATCH 7/9] cli: Add auto complete support about sub options

Cole Robinson crobinso at redhat.com
Sun Nov 18 01:53:51 UTC 2018


On 11/14/2018 03:12 AM, Lin Ma wrote:
> With this patchset, the sub options completion is available. ex:
> 
> $ virt-install --disk <TAB><TAB>
> ...
> bus=    cache=      format=     path=   serial=     size=
> ...
> 
> $ virt-install --disk path=test.qcow2,cache=none,<TAB><TAB>
> ...
> bus=    format=     serial=     size=
> ...
> 
> $ virt-install --disk bu<TAB><TAB>
> Then the sub option 'bus' will be auto completed with a '='
> $ virt-install --disk bus=
> 
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>   virtinst/cli.py | 84 ++++++++++++++++++++++++-------------------------
>   1 file changed, 42 insertions(+), 42 deletions(-)
> 
> diff --git a/virtinst/cli.py b/virtinst/cli.py
> index d46155f7..267997b3 100644
> --- a/virtinst/cli.py
> +++ b/virtinst/cli.py
> @@ -558,7 +558,7 @@ def add_misc_options(grp, prompt=False, replace=False,
>           grp.add_argument("--check", action="append",
>               help=_("Enable or disable validation checks. Example:\n"
>                      "--check path_in_use=off\n"
> -                   "--check all=off"))
> +                   "--check all=off")).completer = completer

The formatting of this kinda offends me :) but I see that it's the 
recommended method in argcomplete docs so I'm just whining.

I wonder if we can do something like iterate over VIRT_PARSERS, compare 
cli_arg_name against the parser's arguments, and set completer 
programmatically that way. Will make it future proof and ensure we don't 
miss adding it for future additions.

If you want to take a stab at it for v2 that's cool, but it's not a 
requirement

Thanks,
Cole




More information about the virt-tools-list mailing list