mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
commit
25cf37a090
7 changed files with 79 additions and 1 deletions
|
@ -18,3 +18,4 @@ All of the ways that xonsh completes you.
|
|||
path
|
||||
python
|
||||
tools
|
||||
xompletions
|
||||
|
|
11
docs/api/completers/xompletions.rst
Normal file
11
docs/api/completers/xompletions.rst
Normal file
|
@ -0,0 +1,11 @@
|
|||
.. _xonsh_completers_xompletions:
|
||||
|
||||
*********************************************************
|
||||
Completion Xompletions (``xonsh.completers.xompletions``)
|
||||
*********************************************************
|
||||
|
||||
.. automodule:: xonsh.completers.xompletions
|
||||
:members:
|
||||
:undoc-members:
|
||||
:inherited-members:
|
||||
|
|
@ -378,7 +378,7 @@ def make_events():
|
|||
title, docstr = docstr.split('\n', 1)
|
||||
docstr = docstr.strip()
|
||||
under = '.' * (len(title) + 4)
|
||||
s += sec.format(low=var.lower(), title=title, under=under,
|
||||
s += sec.format(low=name.lower(), title=title, under=under,
|
||||
docstr=docstr)
|
||||
s = s[:-9]
|
||||
fname = os.path.join(os.path.dirname(__file__), 'eventsbody')
|
||||
|
|
13
news/xompletion.rst
Normal file
13
news/xompletion.rst
Normal file
|
@ -0,0 +1,13 @@
|
|||
**Added:**
|
||||
|
||||
* Completion for ``xonsh`` builtin functions ``xontrib`` and ``xonfig``
|
||||
|
||||
**Changed:** None
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:** None
|
||||
|
||||
**Security:** None
|
|
@ -12,6 +12,8 @@ else:
|
|||
_sys.modules['xonsh.completers.pip'] = __amalgam__
|
||||
tools = __amalgam__
|
||||
_sys.modules['xonsh.completers.tools'] = __amalgam__
|
||||
xompletions = __amalgam__
|
||||
_sys.modules['xonsh.completers.xompletions'] = __amalgam__
|
||||
_aliases = __amalgam__
|
||||
_sys.modules['xonsh.completers._aliases'] = __amalgam__
|
||||
commands = __amalgam__
|
||||
|
|
|
@ -11,6 +11,7 @@ from xonsh.completers.python import (complete_python, complete_import,
|
|||
complete_python_mode)
|
||||
from xonsh.completers.commands import complete_skipper
|
||||
from xonsh.completers.completer import complete_completer
|
||||
from xonsh.completers.xompletions import complete_xonfig, complete_xontrib
|
||||
|
||||
|
||||
def default_completers():
|
||||
|
@ -23,6 +24,8 @@ def default_completers():
|
|||
('pip', complete_pip),
|
||||
('cd', complete_cd),
|
||||
('rmdir', complete_rmdir),
|
||||
('xonfig', complete_xonfig),
|
||||
('xontrib', complete_xontrib),
|
||||
('bash', complete_from_bash),
|
||||
('man', complete_from_man),
|
||||
('import', complete_import),
|
||||
|
|
48
xonsh/completers/xompletions.py
Normal file
48
xonsh/completers/xompletions.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
"""Provides completions for xonsh internal utilities"""
|
||||
|
||||
import xonsh.xontribs as xx
|
||||
import xonsh.tools as xt
|
||||
|
||||
|
||||
def complete_xonfig(prefix, line, start, end, ctx):
|
||||
"""Completion for ``xonfig``"""
|
||||
args = line.split(' ')
|
||||
if len(args) == 0 or args[0] != 'xonfig':
|
||||
return None
|
||||
curix = args.index(prefix)
|
||||
if curix == 1:
|
||||
possible = {'info', 'wizard', 'styles', 'colors', '-h'}
|
||||
elif curix == 2 and args[1] == 'colors':
|
||||
possible = set(xt.color_style_names())
|
||||
else:
|
||||
raise StopIteration
|
||||
return {i for i in possible if i.startswith(prefix)}
|
||||
|
||||
|
||||
def _list_installed_xontribs():
|
||||
meta = xx.xontrib_metadata()
|
||||
installed = []
|
||||
for md in meta['xontribs']:
|
||||
name = md['name']
|
||||
spec = xx.find_xontrib(name)
|
||||
if spec is not None:
|
||||
installed.append(spec.name.rsplit('.')[-1])
|
||||
|
||||
return installed
|
||||
|
||||
|
||||
def complete_xontrib(prefix, line, start, end, ctx):
|
||||
"""Completion for ``xontrib``"""
|
||||
args = line.split(' ')
|
||||
if len(args) == 0 or args[0] != 'xontrib':
|
||||
return None
|
||||
curix = args.index(prefix)
|
||||
if curix == 1:
|
||||
possible = {'list', 'load'}
|
||||
elif curix == 2:
|
||||
if args[1] == 'load':
|
||||
possible = _list_installed_xontribs()
|
||||
else:
|
||||
raise StopIteration
|
||||
|
||||
return {i for i in possible if i.startswith(prefix)}
|
Loading…
Add table
Reference in a new issue