diff -r 91cb012d779a -r 3de41719d7eb bash-completion.sh --- a/bash-completion.sh Sun May 31 16:56:07 2020 +0200 +++ b/bash-completion.sh Sun May 31 21:20:24 2020 +0200 @@ -13,6 +13,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +_relpipe_tr_sql_completion_dsn() { + if type relpipe-out-nullbyte &> /dev/null; then + relpipe-tr-sql --list-data-sources | relpipe-out-nullbyte | while read -r -d '' name; do read -r -d '' description; echo $name; done + fi +} + _relpipe_tr_sql_completion() { local w0 w1 w2 @@ -27,6 +33,12 @@ "boolean" ) + DATA_SOURCE_URL=( + "Driver=SQLite3;Database=file::memory:" + "Driver=SQLite3;Database=file:temp-relpipe.sqlite" + "Driver=SQLite3;Database=file:/tmp/relpipe.sqlite" + ) + if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") elif [[ "$w2" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=('"SELECT * FROM "') elif [[ "$w1" == "--type-cast" && "x$w0" == "x" ]]; then COMPREPLY=("''") @@ -35,8 +47,8 @@ elif [[ "$w1" == "--copy" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") elif [[ "$w1" == "--copy-renamed" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") elif [[ "$w2" == "--copy-renamed" && "x$w0" == "x" ]]; then COMPREPLY=("'copy_of_\$0'") - elif [[ "$w1" == "--file" ]]; then COMPREPLY=($(compgen -f "$w0")) - elif [[ "$w1" == "--file-keep" ]]; then COMPREPLY=($(compgen -W "true false auto" -- "$w0")) + elif [[ "$w1" == "--data-source-name" ]]; then COMPREPLY=($(compgen -W "$(_relpipe_tr_sql_completion_dsn)" -- "$w0")) + elif [[ "$w1" == "--data-source-url" ]]; then COMPREPLY=($(compgen -W "${DATA_SOURCE_URL[*]}" -- "$w0")) else OPTIONS=( "--relation" @@ -44,9 +56,9 @@ "--parameter" "--copy" "--copy-renamed" - "--file" - "--file-keep" "--list-data-sources" + "--data-source-name" + "--data-source-url" ) COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) fi