added main dart completion

pull/1334/head
tbhaxor 2019-02-24 21:47:12 +05:30
parent f02dab437a
commit 995dd04d24
No known key found for this signature in database
GPG Key ID: 2CE3F4D1406EED1A
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#!/bin/bash
# ------------------------------------
# Original Credits : https://github.com/claudiodangelis/dart-bash_completion
# ------------------------------------
if command -v dart > /dev/null; then
__dart() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Options
opts="--help --checked --package-root --version"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [[ ${prev} != *.dart ]] ; then
local dart_scripts=$(for d in `ls -1 *.dart 2>/dev/null`; do echo ${d}; done)
COMPREPLY=( $(compgen -W "${dart_scripts}" -- ${cur}) )
else
COMPREPLY=()
return 0
fi
}
complete -o default -F __dart dart
fi