Added first version of console autocompletion

This commit is contained in:
2020-06-09 22:26:47 +02:00
parent d7573f095f
commit af3a3ffe92
23 changed files with 1314 additions and 88 deletions
+5 -28
View File
@@ -1,12 +1,9 @@
import getopt
import sys
from os import path
import click
import core.utils
from core.sheerka.Sheerka import Sheerka
from prompt_toolkit import prompt
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.history import FileHistory
from repl.SheerkaPrompt import SheerkaPrompt
def usage():
@@ -29,7 +26,7 @@ def main(argv):
return True
if o in ('-d', "--debug"):
debug = True
if o in ('-l', '-logger'):
if o in ('-l', '--logger'):
loggers.add(a)
if o in ('-i', '--interactive'):
interactive = True
@@ -39,30 +36,10 @@ def main(argv):
sheerka = Sheerka(debug=debug, loggers=loggers)
sheerka.initialize()
history_file = path.abspath(path.join(path.expanduser("~"), ".sheerka", "history.txt"))
if interactive:
while True:
try:
_in = prompt('sheerka> ',
history=FileHistory(history_file),
auto_suggest=AutoSuggestFromHistory(),
)
if _in in ("exit", "quit", "bye"):
print("Take care.")
break
if _in == '__':
_in = click.edit()
result = sheerka.evaluate_user_input(_in)
sheerka.print(result)
except KeyboardInterrupt:
continue
except EOFError:
print("EOFError...")
sys.exit(3)
sys.exit(0)
result = SheerkaPrompt(sheerka).run()
sys.exit(result)
else:
_in = core.utils.sysarg_to_string(args)
result = sheerka.evaluate_user_input(_in)