about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2022-04-03 18:34:00 +0200
committerMikael Magnusson <mikachu@gmail.com>2022-04-03 18:34:00 +0200
commita07d0109813fc8ec1722e19d759c417f7b456580 (patch)
tree49fbe026fbad7161f1f224b0d8d467527da0a6fa /Completion
parent1b62a5a0af0a189ec3acd5781f77145dcfad15ed (diff)
downloadzsh-a07d0109813fc8ec1722e19d759c417f7b456580.tar.gz
zsh-a07d0109813fc8ec1722e19d759c417f7b456580.tar.xz
zsh-a07d0109813fc8ec1722e19d759c417f7b456580.zip
49964: _adb: Complete services for start/stop
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_adb16
1 files changed, 15 insertions, 1 deletions
diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb
index a429954a8..8d3eec542 100644
--- a/Completion/Unix/Command/_adb
+++ b/Completion/Unix/Command/_adb
@@ -195,6 +195,9 @@ _adb_dispatch_shell () {
     (dumpsys)
       (( $+functions[_adb_dumpsys_handler] )) && _adb_dumpsys_handler
       ;;
+    (start|stop)
+      (( $+functions[_adb_startstop] )) && _adb_startstop ${words[2]}
+      ;;
     (*)
       _arguments '*: :_adb_remote_folder'
       ;;
@@ -339,6 +342,17 @@ _adb_dumpsys_handler () {
   _wanted dumpsys expl 'dumpsys service' compadd ${services%$'\r'}
 }
 
+(( $+functions[_adb_startstop] )) ||
+_adb_startstop () {
+  local -a services
+  local -A service_status
+  services=(${(f)"$(adb ${ADB_DEVICE_SPECIFICATION} exec-out getprop)"})
+  service_status=( ${(s,: ,)${(j,: ,)${(M)services:#\[init.svc.*}}} )
+  local -A map=(start stopped stop running)
+  services=( ${(k)service_status[(R)*$map[$1]*]} )
+  _wanted services expl "$map[$1] services" compadd - ${${${services#\[}%\]}#init.svc.}
+}
+
 (( $+functions[_adb_dispatch_uninstall] )) ||
 _adb_dispatch_uninstall () {
   _arguments \
@@ -486,7 +500,7 @@ _adb_options_handler() {
 (( $+functions[_adb_shell_commands_handler] )) ||
 _adb_shell_commands_handler() {
   local expl
-  _wanted adb_shell_commands expl 'adb shell command' compadd ls pm am mkdir rmdir rm cat cmd dumpsys
+  _wanted adb_shell_commands expl 'adb shell command' compadd ls pm am mkdir rmdir rm cat cmd dumpsys start stop
 }
 
 (( $+functions[_adb_device_available] )) ||