add all option names to xonfig completer.

This commit is contained in:
Bob Hyman 2020-09-14 23:29:11 -04:00
parent 27b304d99a
commit d37848db20
2 changed files with 6 additions and 7 deletions

View file

@ -2,6 +2,7 @@
import xonsh.xontribs as xx
import xonsh.tools as xt
from xonsh.xonfig import XONFIG_MAIN_ACTIONS
def complete_xonfig(prefix, line, start, end, ctx):
@ -11,7 +12,7 @@ def complete_xonfig(prefix, line, start, end, ctx):
return None
curix = args.index(prefix)
if curix == 1:
possible = {"info", "wizard", "styles", "colors", "-h"}
possible = set(XONFIG_MAIN_ACTIONS.keys()) | {"-h"}
elif curix == 2 and args[1] == "colors":
possible = set(xt.color_style_names())
else:

View file

@ -535,9 +535,7 @@ def _info(ns):
jup_kernel = jup_ksm.find_kernel_specs()[XONSH_JUPYTER_KERNEL]
except (ImportError, KeyError):
pass
data.extend(
[("on jupyter", jup_ksm is not None), ("jupyter kernel", jup_kernel),]
)
data.extend([("on jupyter", jup_ksm is not None), ("jupyter kernel", jup_kernel)])
formatter = _xonfig_format_json if ns.json else _xonfig_format_human
s = formatter(data)
@ -744,7 +742,7 @@ def _xonfig_create_parser():
return p
_XONFIG_MAIN_ACTIONS = {
XONFIG_MAIN_ACTIONS = {
"info": _info,
"web": _web,
"wizard": _wizard,
@ -758,7 +756,7 @@ _XONFIG_MAIN_ACTIONS = {
def xonfig_main(args=None):
"""Main xonfig entry point."""
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")
parser = _xonfig_create_parser()
@ -766,7 +764,7 @@ def xonfig_main(args=None):
ns.orig_args = args
if ns.action is None: # apply default action
ns = parser.parse_args(["info"] + args)
return _XONFIG_MAIN_ACTIONS[ns.action](ns)
return XONFIG_MAIN_ACTIONS[ns.action](ns)
@lazyobject