xonsh/xompletions/rmdir.py
Noorhteen Raja NJ e76115676b
improve completers (#4648)
* 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>
2022-01-27 21:22:36 +05:30

14 lines
531 B
Python

from xonsh.completers.path import complete_dir
from xonsh.parsers.completion_context import CommandContext
def xonsh_complete(ctx: CommandContext):
"""
Completion for "rmdir", includes only valid directory names.
"""
# if starts with the given prefix then it will get completions from man page
if not ctx.prefix.startswith("-") and ctx.arg_index > 0:
comps, lprefix = complete_dir(ctx)
if not comps:
raise StopIteration # no further file completions
return comps, lprefix