From a07d0109813fc8ec1722e19d759c417f7b456580 Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 3 Apr 2022 18:34:00 +0200 Subject: 49964: _adb: Complete services for start/stop --- Completion/Unix/Command/_adb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Completion') 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] )) || -- cgit 1.4.1