[virt-tools-list] [virt-manager] [RFC PATCH 3/9] virt-install: Add auto complete support for the general options

Cole Robinson crobinso at redhat.com
Sun Nov 18 01:45:29 UTC 2018


On 11/14/2018 03:12 AM, Lin Ma wrote:
> With this patchset, the general options completion is available. ex:
> 
> $ virt-install -<TAB><TAB>
> ...
> --arch      --check     --cpu       --dry-run   -h
> --autostart --clock     --cputune   --events    --help
> ...
> 
> $ virt-install --a<TAB><TAB>
> --arch       --autostart
> 
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>   virt-install | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/virt-install b/virt-install
> index 4e16d4c8..4f403706 100755
> --- a/virt-install
> +++ b/virt-install
> @@ -6,6 +6,7 @@
>   # See the COPYING file in the top-level directory.
>   
>   import argparse
> +import argcomplete
>   import atexit
>   import logging
>   import sys
> @@ -864,6 +865,8 @@ def parse_args():
>       cli.add_misc_options(misc, prompt=True, printxml=True, printstep=True,
>                            noreboot=True, dryrun=True, noautoconsole=True)
>   
> +    argcomplete.autocomplete(parser, validator=cli.completer_validator)
> +
>       return parser.parse_args()
>   
>   
> 

Can you make this a function in cli.py, something like

def autocomplete(parser):
     argcomplete.autocomplete(parser, validator=cli.completer_validator)

So we don't need to add argcomplete import everywhere

Thanks,
Cole




More information about the virt-tools-list mailing list