diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2016-12-04 04:32:03 +0100 |
commit | 3e439c3863f14c82f70666804c8570a13b3732e6 (patch) | |
tree | 07036c43e0f3f9242bb6dd42cd2a849ec8ea8aca /Completion/Unix/Command/_adb | |
parent | 2aedc4b88fd0e87b89583983951b04b96f48efd3 (diff) | |
parent | 7b7e84f0815ed22a0ee348a217776529035dccf3 (diff) | |
download | zsh-3e439c3863f14c82f70666804c8570a13b3732e6.tar.gz zsh-3e439c3863f14c82f70666804c8570a13b3732e6.zip |
Merge tag 'zsh-5.2-test-1' into debian
Diffstat (limited to 'Completion/Unix/Command/_adb')
-rw-r--r-- | Completion/Unix/Command/_adb | 153 |
1 files changed, 68 insertions, 85 deletions
diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index 88aca2464..6b56d1748 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -37,34 +37,45 @@ _adb() { local -a ALL_ADB_COMMANDS ALL_ADB_COMMANDS=( + "backup" + "bugreport" "connect" + "devices" + "disable-verity" "disconnect" - "shell" - "wait-for-device" - "push" - "pull" - "logcat" - "jdwp" - "bugreport" - "version" + "emu" + "enable-verity" "forward" - "install" - "uninstall" + "get-devpath" + "get-serialno" + "get-state" "help" - "start-server" + "install" + "install-multiple" + "jdwp" + "keygen" "kill-server" - "devices" - "get-state" - "get-serialno" - "status-window" - "remount" + "logcat" + "ppp" + "pull" + "push" "reboot" "reboot-bootloader" + "remount" + "restore" + "reverse" "root" - "usb" - "tcpip" + "shell" "sideload" - "ppp" + "start-server" + "status-window" + "sync" + "tcpip" + "uninstall" + "unroot" + "usb" + "version" + "wait-for-device" ) (( $+functions[_adb_device_specification] )) && _adb_device_specification @@ -76,7 +87,7 @@ _adb() { '(-d -e )-s[serial]: :_adb_device_serial' \ '( -e -s)-d[device]' \ '(-d -s)-e[emulator]' \ - '1:"options":_adb_options_handler' \ + '1:options:_adb_options_handler' \ '*: : _default' return; @@ -100,25 +111,25 @@ _adb_dispatch_command () { fi case ${curcontext} in - (*:adb-shell) + (*:adb-shell:) (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell ;; - (*:adb-connect|*:adb-disconnect) + (*:adb-connect:|*:adb-disconnect:) (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling ;; - (*:adb-logcat) + (*:adb-logcat:) (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat ;; - (*:adb-push) + (*:adb-push:) (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push ;; - (*:adb-pull) + (*:adb-pull:) (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull ;; - (*:adb-install) + (*:adb-install:) (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install ;; - (*:adb-uninstall) + (*:adb-uninstall:) (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall ;; (*:adb-*) @@ -126,10 +137,10 @@ _adb_dispatch_command () { ;; (*) _arguments \ - '(-d -e)-s["serial"]: :_adb_device_serial' \ - '(-s -e)-d["device"]' \ - '(-d -s)-e["emulator"]' \ - '*:"options":_adb_options_handler' + '(-d -e)-s[serial]: :_adb_device_serial' \ + '(-s -e)-d[device]' \ + '(-d -s)-e[emulator]' \ + '*:options:_adb_options_handler' ;; esac } @@ -191,7 +202,7 @@ _adb_dispatch_shell () { (( $+functions[_adb_package_manager_handler] )) && _adb_package_manager_handler ;; (*) - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' ;; esac } @@ -206,7 +217,7 @@ _adb_pm_list () { (permissions) _arguments -s '-g[organize by group]' \ '-f[print all information]' \ - '-d[only list dangerous pemissions]' \ + '-d[only list dangerous permissions]' \ '-u[only list user visible permissions]' \ '-s[short summary]' \ ':' @@ -271,7 +282,7 @@ _adb_activity_manager_handler () { _arguments -s '-r[print raw results]' \ '-e[set argument NAME to VALUE]:<NAME> <VALUE>:' \ '-p[write profiling data to FILE]:<FILE>:' \ - '-w[wait for instrumenation to finish]' \ + '-w[wait for instrumentation to finish]' \ ':' ;; (profile) @@ -296,7 +307,7 @@ _adb_package_manager_handler () { (( $+functions[_adb_installed_packages] )) && _adb_installed_packages ;; (setInstallLocation) - _wanted set_installlcation expl 'install location' compadd -d "(0:auto 1:internal 2:external)" 0 1 2 + _wanted install-locations expl 'install location' compadd -d "(0:auto 1:internal 2:external)" 0 1 2 ;; (getInstallLocation) ;; @@ -316,8 +327,8 @@ _adb_dispatch_uninstall () { fi _arguments \ - '-k["keep data and cache"]' \ - '*:"installed package":_adb_installed_packages' + '-k[keep data and cache]' \ + '*:installed package:_adb_installed_packages' } (( $+functions[_adb_dispatch_install] )) || @@ -330,10 +341,10 @@ _adb_dispatch_install () { fi _arguments \ - '-l["forward lock"]' \ - '-r["reinstall"]' \ - '-s["install on sd"]' \ - '*:"select apk file":_path_files -g "*(/)|*.apk"' + '-l[forward lock]' \ + '-r[reinstall]' \ + '-s[install on sd]' \ + '*:apk file:_path_files -g "*(/)|*.apk"' } (( $+functions[_adb_dispatch_push] )) || @@ -345,9 +356,9 @@ _adb_dispatch_push () { fi if [[ ${#words} -gt 2 ]] then - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' else - _arguments '*:"local file/folder":_files' + _arguments '*:local file/folder:_files' fi } @@ -360,9 +371,9 @@ _adb_dispatch_pull () { fi if [[ ${#words} -gt 2 ]] then - _arguments '*:"local file/folder":_files' + _arguments '*:local file/folder:_files' else - _arguments '*:adb_remote_folder:_adb_remote_folder' + _arguments '*: :_adb_remote_folder' fi } @@ -453,60 +464,32 @@ _adb_shell_commands_handler() { _wanted adb_shell_commands expl 'adb shell commands' compadd ls pm am mkdir rmdir rm cat } -(( $+functions[_adb_any_device_available] )) || -_adb_any_device_available() { - _any_device_available=${#$(adb devices | sed -n 's/^\([^[:space:]]*\)\t.*$/\1/p')} -} - (( $+functions[_adb_device_available] )) || _adb_device_available() { [[ $(adb ${=ADB_DEVICE_SPECIFICATION} get-state 2>&1) == "device" ]] && return 0 return 1 } -(( $+functions[_adb_full_folder_scan] )) || -_adb_full_folder_scan() { - local -a rv; - rv=( ${$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'for i in $(ls -d /*) - do - case $i in - /proc|/sys|/acct) - ;; - *) - ls -R $i - ;; - esac - done' )//'$\r'/} ) - for line in ${rv[@]}; - do - [[ ${line[1]} == '/' ]] && folder="${line%:}" && adb_device_folders+=$folder && continue; - adb_device_folders+=$folder/$line; - done -} - (( $+functions[_adb_remote_folder] )) || _adb_remote_folder () { - local expl - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_daily - fi - local cacheid=package_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} - typeset -a filesystem_content - if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" - then - local -a adb_device_folders - _adb_full_folder_scan - # remove any duplicates and the initial slash => should still remove bare folders from it when it has children - filesystem_content=( ${(u)adb_device_folders#/} ) - _store_cache "$cacheid" filesystem_content + typeset -a files dirs + local pref=${PREFIX} + if [[ $pref != */* ]]; then + pref= + elif [[ $pref != */ ]]; then + pref=${pref%/*}/ fi + # yes, this ls is sickening to look at, but android doesn't have printf or find + files=(${${(f)"$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'ls -d 2> /dev/null '$pref'*/ '$pref'*')"}%$'\r'}) + dirs=(${${(M)files:#*/}%/}) + files=(${${files:|dirs}:#*\*(/|)}) _adb_device_available && \ - _wanted adb_remote_folder expl 'file/folder on device' _multi_parts $@ -i / filesystem_content + _wanted adb_remote_folder expl 'file/folder on device' _multi_parts $@ / files } (( $+functions[_adb_installed_packages] )) || _adb_installed_packages() { + local update_policy zstyle -s ":completion:${curcontext}:" cache-policy update_policy if [[ -z "$update_policy" ]]; then zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_single_command |