diff --git a/bash/sources/16_keystore b/bash/sources/16_keystore index a25e2b7..205a635 100644 --- a/bash/sources/16_keystore +++ b/bash/sources/16_keystore @@ -20,8 +20,6 @@ if [ -f "$RBASH_HOME/keystore.secret" ]; then _AUTH_SECRET=$( cat "$RBASH_HOME/keystore.secret" ) fi -complete -W "add del get list query update search secret" kstore - function kstore { case $1 in add) shift; _kstoreadd "$@" ;; @@ -48,6 +46,34 @@ function kstore { return $? } +function _kstore { + local CUR=${COMP_WORDS[COMP_CWORD]} + local SCOPE=${COMP_WORDS[COMP_CWORD-1]} + local t + + COMPREPLY=() + + case "$SCOPE" in + kstore) + COMPREPLY=( $(compgen -W "add del get list query update search secret" -- $CUR) ) + return + ;; + get|update) + COMPREPLY=( $(compgen -W "$( _kstorequery "SELECT DISTINCT key FROM store" )" -- $CUR) ) + ;; + esac + + t=${COMP_WORDS[COMP_CWORD-2]} + case "$t" in + get|update) + t=`_kstorequote "$SCOPE"` + COMPREPLY=( $(compgen -W "$( _kstorequery "SELECT DISTINCT prop FROM store WHERE key = '$t'" )" -- $CUR) ) + ;; + esac +} + +complete -F _kstore kstore + function _kstoresecret { case "$1" in clear) shift; _kstoresecret-clear "$@" ;; diff --git a/bash/sources/17_kcontext b/bash/sources/17_kcontext index c28ca47..df19590 100644 --- a/bash/sources/17_kcontext +++ b/bash/sources/17_kcontext @@ -24,7 +24,6 @@ function kcontext { function _kcontext { local CUR=${COMP_WORDS[COMP_CWORD]} local SCOPE=${COMP_WORDS[COMP_CWORD-1]} - local t COMPREPLY=()