cli: Fix --check completion

Make the completer functions fold in ParseCLICheck as well
This commit is contained in:
Cole Robinson 2019-01-06 19:01:35 -05:00
parent a31bf70620
commit 4336bdb92d
2 changed files with 8 additions and 2 deletions

View File

@ -1081,6 +1081,7 @@ _add_argcomplete_cmd("virt-install --disk ", "driver.copy_on_read=") # will lis
_add_argcomplete_cmd("virt-install --disk a", "address.base")
_add_argcomplete_cmd("virt-install --disk address.u", "address.unit")
_add_argcomplete_cmd("virt-install --disk address.unit=foo,sg", "sgio")
_add_argcomplete_cmd("virt-install --check d", "disk_size")
_add_argcomplete_cmd("virt-install --test-stub", None,
nogrep="--test-stub-command")
_add_argcomplete_cmd("virt-clone --preserve", "--preserve-data")

View File

@ -458,9 +458,13 @@ def get_meter():
# bash completion helpers #
###########################
def _get_completer_parsers():
return VIRT_PARSERS + [ParseCLICheck]
def _virtparser_completer(prefix, **kwargs):
sub_options = []
for parserclass in VIRT_PARSERS:
for parserclass in _get_completer_parsers():
if kwargs['action'].dest == parserclass.cli_arg_name:
# pylint: disable=protected-access
for arg in sorted(parserclass._virtargs, key=lambda p: p.cliname):
@ -494,7 +498,8 @@ def autocomplete(parser):
import argcomplete
parsernames = ["--" + pclass.cli_arg_name for pclass in VIRT_PARSERS]
parsernames = ["--" + pclass.cli_arg_name for pclass in
_get_completer_parsers()]
# pylint: disable=protected-access
for action in parser._actions:
for opt in action.option_strings: