def finalizeOptions(self, availableTargets: list):
targetOption = self._parser.add_argument("targets", metavar="TARGET", nargs=argparse.ZERO_OR_MORE,
help="The targets to build", choices=availableTargets + [[]])
if argcomplete and "_ARGCOMPLETE" in os.environ:
# if IS_FREEBSD: # FIXME: for some reason this won't work
excludes = ["-t", "--skip-dependencies"]
if sys.platform.startswith("freebsd"):
excludes += ["--freebsd-builder-copy-only", "--freebsd-builder-hostname",
"--freebsd-builder-output-path"]
visibleTargets = availableTargets.copy()
visibleTargets.remove("__run_everything__")
targetCompleter = argcomplete.completers.ChoicesCompleter(visibleTargets)
targetOption.completer = targetCompleter
# make sure we get target completion for the unparsed args too by adding another zero_or more options
# not sure why this works but it's a nice hack
unparsed = self._parser.add_argument("targets", metavar="TARGET", type=list, nargs=argparse.ZERO_OR_MORE,
help=argparse.SUPPRESS, choices=availableTargets)
unparsed.completer = targetCompleter
argcomplete.autocomplete(
self._parser,
always_complete_options=None, # don't print -/-- by default
exclude=excludes, # hide these options from the output
print_suppressed=True, # also include target-specific options
)
评论列表
文章目录