1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00

nux-runner: Improved REPL command support.

Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
Tony Tkáčik 2017-06-21 16:03:51 +02:00
parent 47dcb3daca
commit 041d3b774e

View file

@ -79,6 +79,15 @@ nuxr.repl.process() {
fi
}
nuxr.repl.expose() {
# FIXME: Figure different way of exposing direct functions without wrapping
for cmd in "$@"; do
eval """function repl.command.$cmd {
$cmd "\$@"
}
"""
done
}
##
## repl.command.::
## fallback command which does nothing if user just presses enter.
@ -112,6 +121,13 @@ nuxr.tasks.runtime.search() {
| cut -d"(" -f1
}
nuxr.repl.commands.search() {
set | grep -E "^((repl\\.command)|(task))\\.$1.* ()" \
| sed -re 's/^((repl\.command)|(task))\.//gi' \
| cut -d"(" -f1 | sort | uniq
}
nuxr.repl.completer.help() {
nux.log debug "Help completer"
nux.log debug "current_pos $current_pos"
@ -148,7 +164,7 @@ nuxr.repl.completer() {
fi
local result="";
if [ $current_pos -le 1 ] ; then
result=$(nuxr.tasks.runtime.search $current_word | grep -v "help\\.")
result=$(nuxr.repl.commands.search $current_word | grep -v "help\\.")
elif [ $current_pos -ge 2 ]; then
command=${words[0]}
nux.log debug "Trying to use completer for '$command'"