Updated completion script

This commit is contained in:
Jesse Gardner 2021-04-15 17:39:20 -07:00
parent d0db223eb9
commit 62e36d07e9
1 changed files with 3 additions and 10 deletions

View File

@ -2,21 +2,14 @@
_qq2clone () { _qq2clone () {
[[ -e "${HOME:?}/.config/qq2clone" ]] || return 1 QQ2_DIR="$(<"${HOME:?}/.config/qq2clone")"
QQ2_DIR="$(<"${HOME}/.config/qq2clone")" [[ -e "${QQ2_DIR}/qq2clone.db" ]] || return 1
[[ "$QQ2_DIR" =~ ^[[:space:]]*([^[:space:]].*)$ ]] &&
QQ2_DIR="${BASH_REMATCH[1]}"
[[ "$QQ2_DIR" =~ ^(.*[^[:space:]])[[:space:]]*$ ]] &&
QQ2_DIR="${BASH_REMATCH[1]}"
[[ -e "${QQ2_DIR}/sqlite3" ]] || return 1
chmod +rw "${QQ2_DIR}/sqlite3" &>/dev/null || return 1
declare -a templates declare -a templates
declare line declare line
while read -r line; do while read -r line; do
templates=( "${templates[@]}" "$line" ) templates=( "${templates[@]}" "$line" )
done < <("${QQ2_DIR}/sqlite3" --batch "${QQ2_DIR}/qq2clone.db" \ done < <("sqlite3" --batch "${QQ2_DIR}/qq2clone.db" \
"select name from TEMPLATES") "select name from TEMPLATES")
declare -a COMS FLAGS declare -a COMS FLAGS
COMS=( check clone config connect copy-template delete-template destroy \ COMS=( check clone config connect copy-template delete-template destroy \