diff options
Diffstat (limited to 'completions/_adb')
-rw-r--r-- | completions/_adb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/completions/_adb b/completions/_adb index e8ebab1..0189331 100644 --- a/completions/_adb +++ b/completions/_adb @@ -3,67 +3,67 @@ # Use of this file is deprecated. Upstream completion is available in # the Android SDK, use that instead. -_adb_command_usage() +_comp_cmd_adb__command_usage() { - COMPREPLY=($(compgen -W \ - '$("$1" help 2>&1 | command grep "^ *\(adb \)\? *$2 " \ - | command sed -e "s/[]|[]/\n/g" | _parse_help -)' -- "$cur")) + _comp_compgen_help - <<<"$("$1" help 2>&1 | + command sed -e "/^ *\(adb \)\{0,1\} *$2 /!d;s/[]|[]/\n/g")" } -_adb() +_comp_cmd_adb() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in -s | -p | --algo | --key | --iv) return ;; -f) - _filedir + _comp_compgen_filedir return ;; esac - local cmd i + local cmd has_cmd="" i for ((i = 1; i < cword; i++)); do if [[ ${words[i]} != -* && ${words[i - 1]} != -[sp] ]]; then cmd="${words[i]}" + has_cmd=set break fi done - if [[ ! -v cmd ]]; then + if [[ ! $has_cmd ]]; then local tmp=() if [[ ! $cur || $cur == -* ]]; then - tmp+=($(compgen -W '$(_parse_help "$1" help)' -- "$cur")) + _comp_compgen -av tmp help -- help fi if [[ ! $cur || $cur != -* ]]; then - tmp+=($($1 help 2>&1 | awk '$1 == "adb" { print $2 }')) + _comp_split -a tmp "$("$1" help 2>&1 | _comp_awk '$1 == "adb" { print $2 }')" tmp+=(devices connect disconnect sideload) fi - COMPREPLY=($(compgen -W '${tmp[@]}' -- "$cur")) + ((${#tmp[@]})) && + _comp_compgen -- -W '"${tmp[@]}"' return fi # TODO: more and better command completions - _adb_command_usage "$1" $cmd + _comp_cmd_adb__command_usage "$1" "$cmd" case $cmd in push | restore | sideload) - _filedir + _comp_compgen -a filedir ;; forward) - COMPREPLY=($(compgen -W \ - '$("$1" help 2>&1 | command sed -ne "s/^ *adb *forward *-/-/p" | \ - _parse_help -)' -- "$cur")) + _comp_compgen_help - <<<"$("$1" help 2>&1 | + command sed -ne "s/^ *adb *forward *-/-/p")" ;; reboot) - COMPREPLY=($(compgen -W 'bootloader recovery' -- "$cur")) + _comp_compgen -- -W 'bootloader recovery' ;; esac } && - complete -F _adb adb + complete -F _comp_cmd_adb adb # ex: filetype=sh |