Add extra processing of special commands
This commit is contained in:
parent
68168b91fe
commit
657db23236
10
lib/cli.sh
10
lib/cli.sh
|
@ -6,10 +6,9 @@ get_cmd() {
|
|||
|
||||
parse_cmd() {
|
||||
local cmd=( ) arg
|
||||
declare -n cmd_sent=$1
|
||||
declare -n serialized=$2
|
||||
declare -n serialized=$1
|
||||
|
||||
route_cmd "$3"
|
||||
route_cmd "$2"
|
||||
|
||||
serialized=*${#cmd[@]}$'\r\n'
|
||||
|
||||
|
@ -56,9 +55,10 @@ parse_word() {
|
|||
done
|
||||
|
||||
if ! (( ${#cmd[@]} )); then
|
||||
cmd_sent=${arg^^}
|
||||
cmd+=( "\$${#arg}"$'\r\n'"$cmd_sent"$'\r\n' )
|
||||
redis_cmd=( "${arg^^}" )
|
||||
cmd=( "\$${#arg}"$'\r\n'"${arg^^}"$'\r\n' )
|
||||
else
|
||||
redis_cmd+=( "$arg" )
|
||||
cmd+=( "\$${#arg}"$'\r\n'"$arg"$'\r\n' )
|
||||
fi
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ parse_res() {
|
|||
parse_simple() {
|
||||
(( lines_left -= 1 ))
|
||||
printf '%s\n' "${1:1}"
|
||||
|
||||
if [[ ${redis_cmd[0]} = SELECT && ${1:1} = OK ]]; then
|
||||
table=${redis_cmd[1]}
|
||||
fi
|
||||
}
|
||||
|
||||
parse_int() {
|
||||
|
|
|
@ -28,7 +28,14 @@ fi
|
|||
###
|
||||
|
||||
while get_cmd line; do
|
||||
parse_cmd redis_cmd redis_line "$line"
|
||||
redis_cmd=( )
|
||||
|
||||
parse_cmd redis_line "$line"
|
||||
|
||||
if [[ ${redis_cmd[0]} = EXIT ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
redis_send "$redis_line"
|
||||
|
||||
lines_left=1
|
||||
|
|
Loading…
Reference in New Issue