mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
add all option names to xonfig completer.
This commit is contained in:
parent
27b304d99a
commit
d37848db20
2 changed files with 6 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import xonsh.xontribs as xx
|
import xonsh.xontribs as xx
|
||||||
import xonsh.tools as xt
|
import xonsh.tools as xt
|
||||||
|
from xonsh.xonfig import XONFIG_MAIN_ACTIONS
|
||||||
|
|
||||||
|
|
||||||
def complete_xonfig(prefix, line, start, end, ctx):
|
def complete_xonfig(prefix, line, start, end, ctx):
|
||||||
|
@ -11,7 +12,7 @@ def complete_xonfig(prefix, line, start, end, ctx):
|
||||||
return None
|
return None
|
||||||
curix = args.index(prefix)
|
curix = args.index(prefix)
|
||||||
if curix == 1:
|
if curix == 1:
|
||||||
possible = {"info", "wizard", "styles", "colors", "-h"}
|
possible = set(XONFIG_MAIN_ACTIONS.keys()) | {"-h"}
|
||||||
elif curix == 2 and args[1] == "colors":
|
elif curix == 2 and args[1] == "colors":
|
||||||
possible = set(xt.color_style_names())
|
possible = set(xt.color_style_names())
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -535,9 +535,7 @@ def _info(ns):
|
||||||
jup_kernel = jup_ksm.find_kernel_specs()[XONSH_JUPYTER_KERNEL]
|
jup_kernel = jup_ksm.find_kernel_specs()[XONSH_JUPYTER_KERNEL]
|
||||||
except (ImportError, KeyError):
|
except (ImportError, KeyError):
|
||||||
pass
|
pass
|
||||||
data.extend(
|
data.extend([("on jupyter", jup_ksm is not None), ("jupyter kernel", jup_kernel)])
|
||||||
[("on jupyter", jup_ksm is not None), ("jupyter kernel", jup_kernel),]
|
|
||||||
)
|
|
||||||
|
|
||||||
formatter = _xonfig_format_json if ns.json else _xonfig_format_human
|
formatter = _xonfig_format_json if ns.json else _xonfig_format_human
|
||||||
s = formatter(data)
|
s = formatter(data)
|
||||||
|
@ -744,7 +742,7 @@ def _xonfig_create_parser():
|
||||||
return p
|
return p
|
||||||
|
|
||||||
|
|
||||||
_XONFIG_MAIN_ACTIONS = {
|
XONFIG_MAIN_ACTIONS = {
|
||||||
"info": _info,
|
"info": _info,
|
||||||
"web": _web,
|
"web": _web,
|
||||||
"wizard": _wizard,
|
"wizard": _wizard,
|
||||||
|
@ -758,7 +756,7 @@ _XONFIG_MAIN_ACTIONS = {
|
||||||
def xonfig_main(args=None):
|
def xonfig_main(args=None):
|
||||||
"""Main xonfig entry point."""
|
"""Main xonfig entry point."""
|
||||||
if not args or (
|
if not args or (
|
||||||
args[0] not in _XONFIG_MAIN_ACTIONS and args[0] not in {"-h", "--help"}
|
args[0] not in XONFIG_MAIN_ACTIONS and args[0] not in {"-h", "--help"}
|
||||||
):
|
):
|
||||||
args.insert(0, "info")
|
args.insert(0, "info")
|
||||||
parser = _xonfig_create_parser()
|
parser = _xonfig_create_parser()
|
||||||
|
@ -766,7 +764,7 @@ def xonfig_main(args=None):
|
||||||
ns.orig_args = args
|
ns.orig_args = args
|
||||||
if ns.action is None: # apply default action
|
if ns.action is None: # apply default action
|
||||||
ns = parser.parse_args(["info"] + args)
|
ns = parser.parse_args(["info"] + args)
|
||||||
return _XONFIG_MAIN_ACTIONS[ns.action](ns)
|
return XONFIG_MAIN_ACTIONS[ns.action](ns)
|
||||||
|
|
||||||
|
|
||||||
@lazyobject
|
@lazyobject
|
||||||
|
|
Loading…
Add table
Reference in a new issue