Files
mdbtools/src/util/bash-completion/mdb-import
Nirgal Vourgère 9e50c7401d Modernize bash-completion
Use _init_completion
Support long options with or without =
Auto generate options from the --help using _parse_help
2020-10-27 00:05:26 +01:00

31 lines
740 B
Bash

#-*- mode: shell-script;-*-
_mdb_import()
{
local cur prev words cword split
_init_completion -s || return
if [[ "$prev" == -@(H|--header|d|-delimiter) ]]; then
return 0
fi
$split && return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--header= --delimiter= --help' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
elif [[ "$prev" == @(*mdb|*mdw|*accdb) ]]; then
local dbname
local tablenames
dbname=$prev
__expand_tilde_by_ref dbname
local IFS=$'\n'
tablenames="$(eval mdb-tables -S -1 "${dbname}" 2>/dev/null)"
compopt -o filenames
COMPREPLY=( $( compgen -W '${tablenames}' -- "$cur" ) )
else
_filedir '@(mdb|mdw|accdb|txt|csv)'
fi
return 0
} &&
complete -F _mdb_import mdb-import