xonsh/xompletions/xonsh.py
Noorhteen Raja NJ 039294c362
Xompletions (#4521)
* feat: add command completers logic

* feat: implement xompleter logic

* fix: handle callable object in exception

* chore: add xompletions package to setup.py

* fix: update tests for changes to command completer logic

* docs:

* fix: qa errors

fixes #4514

* feat: add xonsh completions

* refactor: split module matcher to separate class

* feat: add django-admin completions

* fix: failing tests

* feat: add more properties to completion-context

* refactor: cleanup code

* todo item add
2022-01-10 11:21:22 -05:00

17 lines
620 B
Python

from xonsh.cli_utils import ArgparseCompleter
from xonsh.completers.tools import get_filter_function
from xonsh.parsers.completion_context import CommandContext
def xonsh_complete(command: CommandContext):
"""Completer for ``xonsh`` command using its ``argparser``"""
from xonsh.main import parser
completer = ArgparseCompleter(parser, command=command)
fltr = get_filter_function()
for comp in completer.complete():
if fltr(comp, command.prefix):
yield comp
# todo: part of return value will have unfiltered=False/True. based on that we can use fuzzy to rank the results