| 1 |
#-*- mode: shell-script;-*- |
| 2 |
_mdb_json() |
| 3 |
{ |
| 4 |
local cur prev words cword split |
| 5 |
_init_completion -s || return |
| 6 |
|
| 7 |
if [[ "$prev" == -@(D|-date-format|T|-datetime-format|U|--no-unprintable|h|-help) ]] ; then |
| 8 |
return 0 |
| 9 |
fi |
| 10 |
|
| 11 |
$split && return |
| 12 |
|
| 13 |
if [[ "$cur" == -* ]]; then |
| 14 |
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) |
| 15 |
[[ $COMPREPLY == *= ]] && compopt -o nospace |
| 16 |
elif [[ "$prev" == *@(mdb|mdw|accdb) ]] ; then |
| 17 |
local dbname |
| 18 |
local tablenames |
| 19 |
dbname=$prev |
| 20 |
__expand_tilde_by_ref dbname |
| 21 |
local IFS=$'\n' |
| 22 |
tablenames="$(eval mdb-tables -S -1 "${dbname}" 2>/dev/null)" |
| 23 |
compopt -o filenames |
| 24 |
COMPREPLY=( $( compgen -W '${tablenames}' -- "$cur" ) ) |
| 25 |
else |
| 26 |
_filedir '@(mdb|mdw|accdb)' |
| 27 |
fi |
| 28 |
return 0 |
| 29 |
} && |
| 30 |
complete -F _mdb_json mdb-json |