1
0
Fork 0

Merging upstream version 4.3.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-03-24 15:47:19 +01:00
parent cc0be9576d
commit 7736adc9ff
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
10 changed files with 197 additions and 33 deletions

View file

@ -3,9 +3,9 @@ _pg_databases()
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
# "Access privileges" in output may contain linefeeds, hence the NF > 1
COMPREPLY=( $( compgen -W "$( psql -AtqwlF $'\t' 2>/dev/null | \
awk 'NF > 1 { print $1 }' )" -- "$cur" ) )
awk 'NF > 1 { print $1 }' )" -- "$cur" ) )
}
_pg_users()
{
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
@ -13,12 +13,23 @@ _pg_users()
template1 2>/dev/null )" -- "$cur" ) )
[[ ${#COMPREPLY[@]} -eq 0 ]] && COMPREPLY=( $( compgen -u -- "$cur" ) )
}
_pg_services()
{
# return list of available services
local services
if [[ -f "$HOME/.pg_service.conf" ]]; then
services=$(grep -oP '(?<=^\[).*?(?=\])' "$HOME/.pg_service.conf")
fi
local suffix="${cur#*=}"
COMPREPLY=( $(compgen -W "$services" -- "$suffix") )
}
_pgcli()
{
local cur prev words cword
_init_completion -s || return
case $prev in
-h|--host)
_known_hosts_real "$cur"
@ -39,23 +50,27 @@ _pgcli()
esac
case "$cur" in
--*)
# return list of available options
COMPREPLY=( $( compgen -W '--host --port --user --password --no-password
--single-connection --version --dbname --pgclirc --dsn
--row-limit --help' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
;;
-)
# only complete long options
compopt -o nospace
COMPREPLY=( -- )
return 0
;;
*)
service=*)
_pg_services
return 0
;;
--*)
# return list of available options
COMPREPLY=( $( compgen -W '--host --port --user --password --no-password
--single-connection --version --dbname --pgclirc --dsn
--row-limit --help' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
;;
-)
# only complete long options
compopt -o nospace
COMPREPLY=( -- )
return 0
;;
*)
# return list of available databases
_pg_databases
_pg_databases
esac
} &&
} &&
complete -F _pgcli pgcli