Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH 4/8: _adb: Complete services for start/stop



From: Mikael Magnusson <mikael.magnusson@xxxxxxxx>

---
 Completion/Unix/Command/_adb | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb
index a429954a88..8d3eec5427 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] )) ||
-- 
2.15.1





Messages sorted by: Reverse Date, Date, Thread, Author