Exemplo n.º 1
0
    def _complete(self, act: ap.Action, **kwargs):
        if hasattr(act, "completer") and callable(act.completer):  # type: ignore
            # call the completer function
            kwargs.update(self.kwargs)
            yield from act.completer(xsh=XSH, action=act, completer=self, **kwargs)  # type: ignore

        if (
            hasattr(act, "choices")
            and act.choices
            and not isinstance(act.choices, dict)
        ):
            # any sequence or iterable
            yield from act.choices
Exemplo n.º 2
0
    def _complete(self, act: ap.Action, **kwargs):
        if act.choices:
            yield from act.choices
        elif hasattr(act, "completer") and callable(
                act.completer):  # type: ignore
            # call the completer function
            from xonsh.built_ins import XSH

            kwargs.update(self.kwargs)
            yield from act.completer(xsh=XSH,
                                     action=act,
                                     completer=self,
                                     **kwargs)  # type: ignore
Exemplo n.º 3
0
def register_completer(action: argparse.Action, completer) -> None:
    """Register the given completer with the specified action."""
    action.completer = completer  # type: ignore[attr-defined]  # intentionally using an attribute that does not exist