From c98ad7e9e27923a8fc997e9722ab09f169af8f17 Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Tue, 9 Aug 2011 20:33:17 +0200 Subject: [PATCH] #40 adb: Complete uninstall command with package names from the device --- _adb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/_adb b/_adb index a268f52..17622f0 100644 --- a/_adb +++ b/_adb @@ -46,21 +46,25 @@ typeset -A opt_args -local context state line curcontext="$curcontext" +local context state line curcontext="$curcontext" adb_cmd _adb() { local ret=1 + + adb_cmd="$words[1]" _arguments -C \ - '(-e -s)-d[directs command to the only connected USB device, returns an error if more than one USB device is present]' \ - '(-d -s)-e[directs command to the only running emulator, returns an error if more than one emulator is running]' \ - '(-d -e)-s[directs command to the USB device or emulator with the given serial number]: :_adb_serial_numbers' \ - '-p[simple product name or a relative/absolute path to a product out directory]: :_adb_products' \ + '(-e -s)-d[directs command to the only connected USB device, returns an error if more than one USB device is present]' \ + '(-d -s)-e[directs command to the only running emulator, returns an error if more than one emulator is running]' \ + '(-d -e)-s[directs command to the USB device or emulator with the given serial number]: :_adb_serial_numbers' \ + '-p[simple product name or a relative/absolute path to a product out directory]: :_adb_products' \ '1: :_adb_cmds' \ '*::arg:->args' \ && ret=0 - case $state in + adb_cmd+=" ${(fkv)opt_args[(I)-d|-e|-s|-p]}" + + case "$state" in (args) curcontext="${curcontext%:*:*}:adb-cmd-$words[1]:" case $words[1] in @@ -126,10 +130,9 @@ _adb() { && ret=0 ;; (uninstall) - # TODO Somehow complete package names ? _arguments \ '-k[keep the data and cache directories]' \ - '1::package' \ + '1: :_adb_packages' \ && ret=0 ;; (reboot) @@ -231,6 +234,12 @@ _adb_serial_numbers() { _describe -t serial-numbers 'serial number' serial_numbers "$@" && ret=0 } +(( $+functions[_adb_packages] )) || +_adb_packages() { + local packages; packages=($(_call_program packages $adb_cmd shell 'ls /data/data')) + _multi_parts . packages +} + (( $+functions[_adb_host_colon_ports] )) || _adb_host_colon_ports() { local ret=1