mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00

* fix: pip -r appends spaces at the end modularize completing output from subproc-out * docs: * fix: flake8 * fix: failing pip comp tests * refactor: naming xonsh conflicts with actual package the IDE completions don't work. we add this naming convention instead. * feat: option to filter after completion returned this will help reduce some boilerplate, and we can enrich the filtering behaviour * feat: add gh completions * fix: filtering out completions * refactor: simplify invoking completer interface * test: add fixture for xsh with os-env * test: add tests for gh-completions * fix: flake error * fix: mypy errors and update gh completer tests * fix: handle cross-platform line endings * feat: include man,bash completer only if available * todo: improve man page completions * fix: failing man page tests * fix: py 3.7 compatibility * fix: qa error * fix: stop dir completions * feat: improve man page completions now shows descriptions, recognizes more number of options correctly * fix: update man page completions * feat: support filtering based on display as well * Update xonsh/completer.py Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com> * style: * test: xfail ptk-shell tests on windows Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
25 lines
811 B
Python
25 lines
811 B
Python
"""Completers for gh CLI"""
|
|
|
|
from xonsh.completers.tools import sub_proc_get_output, completion_from_cmd_output
|
|
from xonsh.parsers.completion_context import CommandContext
|
|
|
|
|
|
def _complete(cmd, *args):
|
|
out, _ = sub_proc_get_output(cmd, "__complete", *args)
|
|
if out:
|
|
# directives
|
|
# shellCompDirectiveError 1
|
|
# shellCompDirectiveNoSpace 2
|
|
# shellCompDirectiveNoFileComp 4
|
|
# shellCompDirectiveFilterFileExt 8
|
|
# shellCompDirectiveFilterDirs 16
|
|
# todo: implement directive-numbers above
|
|
*lines, dir_num = out.decode().splitlines()
|
|
for ln in lines:
|
|
yield completion_from_cmd_output(ln)
|
|
|
|
|
|
def xonsh_complete(ctx: CommandContext):
|
|
cmd, *args = [arg.value for arg in ctx.args] + [ctx.prefix]
|
|
|
|
return _complete(cmd, *args)
|