From 0669da315b1453e2bcc0612ca20c7fc5a56d1d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Sun, 14 Aug 2022 02:01:33 +0800 Subject: [PATCH] added kstore-search --- bash/bashrc/sources/16_keystore | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bash/bashrc/sources/16_keystore b/bash/bashrc/sources/16_keystore index 4142b20..d75ac69 100644 --- a/bash/bashrc/sources/16_keystore +++ b/bash/bashrc/sources/16_keystore @@ -33,10 +33,10 @@ function kstore { *) __func_head "add [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]" __func_help "update [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]" - __func_help "get key [prop, default: $_KSTORE_DEF_PROP]" + __func_help "get [key] [prop, default: $_KSTORE_DEF_PROP]" + __func_help "del [key]" __func_help "list" - __func_help "del key" - __func_help "search key" + __func_help "search [key] [prop]" __func_help "secret ..." __func_help "query SQL" return 1 @@ -288,7 +288,12 @@ function kstore-del { } function kstore-search { - echo "Not implemented yet" + local _termk _termp _cond + _termk=`kstore-quote "$1"` + _termp=`kstore-quote "$2"` + _cond="key LIKE '%$_termk%' AND prop LIKE '%$_termp%'" + + $_SQLITE -header -column "$_AUTH_DB" "SELECT key, prop, length( data ) FROM store WHERE $_cond;" } function kstore-list {