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:
parent
47dcb3daca
commit
041d3b774e
1 changed files with 17 additions and 1 deletions
|
|
@ -79,6 +79,15 @@ nuxr.repl.process() {
|
||||||
fi
|
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.::
|
## repl.command.::
|
||||||
## fallback command which does nothing if user just presses enter.
|
## fallback command which does nothing if user just presses enter.
|
||||||
|
|
@ -112,6 +121,13 @@ nuxr.tasks.runtime.search() {
|
||||||
| cut -d"(" -f1
|
| 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() {
|
nuxr.repl.completer.help() {
|
||||||
nux.log debug "Help completer"
|
nux.log debug "Help completer"
|
||||||
nux.log debug "current_pos $current_pos"
|
nux.log debug "current_pos $current_pos"
|
||||||
|
|
@ -148,7 +164,7 @@ nuxr.repl.completer() {
|
||||||
fi
|
fi
|
||||||
local result="";
|
local result="";
|
||||||
if [ $current_pos -le 1 ] ; then
|
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
|
elif [ $current_pos -ge 2 ]; then
|
||||||
command=${words[0]}
|
command=${words[0]}
|
||||||
nux.log debug "Trying to use completer for '$command'"
|
nux.log debug "Trying to use completer for '$command'"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue