mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-09-18 18:22:07 +08:00
44 lines
1.3 KiB
Bash
44 lines
1.3 KiB
Bash
#-*- mode: shell-script;-*-
|
|
_mdb_export()
|
|
{
|
|
local cur prev
|
|
COMPREPLY=()
|
|
cur=${COMP_WORDS[COMP_CWORD]}
|
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
if [[ "$prev" == -@(d|-delimiter|R|-row-delimiter|q|-quote|X|-escape|N|-namespace|S|-batch-size|D|-date-format|T|-datetime-format|0|-null|h|-help) ]] ; then
|
|
return 0
|
|
elif [[ "$prev" == -@(I|-insert) ]] ; then
|
|
COMPREPLY=( $( compgen -W 'access sybase oracle postgres mysql sqlite' -- $cur ) )
|
|
elif [[ "$prev" == -@(b|-bin) ]] ; then
|
|
COMPREPLY=( $( compgen -W 'strip raw octal hex' -- $cur ) )
|
|
elif [[ "$cur" == -* ]]; then
|
|
COMPREPLY=( $( compgen -W '-H -d -R -Q -q -X -I -N -S -D -T -0 -B -h \
|
|
--no-header --delimiter --row-delimiter \
|
|
--no-quote --quote --escape \
|
|
--insert --namespace --batch-size \
|
|
--date-format --datetime-format \
|
|
--null --bin --boolean-words
|
|
--help' -- $cur ) )
|
|
elif [[ "$prev" == *@(mdb|mdw|accdb) ]] ; then
|
|
local dbname
|
|
local tablenames
|
|
local tablename
|
|
dbname=$prev
|
|
__expand_tilde_by_ref dbname
|
|
local IFS=$'\n'
|
|
tablenames=""
|
|
while read tablename
|
|
do
|
|
#shell-quote each line
|
|
tablenames="$tablenames"$'\n'"$(printf %q "${tablename}")"
|
|
done < <(eval mdb-tables -S -1 "${dbname}" 2>/dev/null)
|
|
compopt -o filenames
|
|
COMPREPLY=( $( compgen -W "${tablenames}" -- $cur ) )
|
|
else
|
|
_filedir '@(mdb|mdw|accdb)'
|
|
fi
|
|
return 0
|
|
} &&
|
|
complete -F _mdb_export mdb-export
|