Merge pull request #696 from nfischer/feat-emulator-avd-completion

Add avd completion to _emulator
This commit is contained in:
Shohei YOSHIDA 2020-03-31 00:57:06 +09:00 committed by GitHub
commit 72b1b8f8c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 3 deletions

View File

@ -18,11 +18,15 @@
typeset -A opt_args typeset -A opt_args
local context state line curcontext="$curcontext" local context state line curcontext="$curcontext"
_list_avds() {
local -a _avds=($HOME/.android/avd/*.ini(N.:t:r))
echo "${_avds[@]}"
}
# TODO All image options are contextual to -sysdir value # TODO All image options are contextual to -sysdir value
# TODO All skin options are contextual to -skindir value # TODO All skin options are contextual to -skindir value
# TODO snapshot options are mutually exclusive # TODO snapshot options are mutually exclusive
# TODO Use '-snapshot-list' output for snapshot names # TODO Use '-snapshot-list' output for snapshot names
# TODO Complete -avd with avd names ?
# TODO -logcat: use completer from _adb # TODO -logcat: use completer from _adb
# TODO Complete options with device values # TODO Complete options with device values
# TODO Complete -prop # TODO Complete -prop
@ -62,7 +66,7 @@ _arguments \
'-snapshot-list[show a list of available snapshots]' \ '-snapshot-list[show a list of available snapshots]' \
'-no-snapshot-update-time[do not do try to correct snapshot time on restore]' \ '-no-snapshot-update-time[do not do try to correct snapshot time on restore]' \
'-wipe-data[reset the user data image (copy it from initdata)]' \ '-wipe-data[reset the user data image (copy it from initdata)]' \
'-avd[use a specific android virtual device]:android virtual device name' \ '-avd[use a specific android virtual device]:android virtual device name:($(_list_avds))' \
'-skindir[search skins in <dir> (default <system>/skins)]: :_files -/' \ '-skindir[search skins in <dir> (default <system>/skins)]: :_files -/' \
'-skin[select a given skin]' \ '-skin[select a given skin]' \
'(-noskin -no-skin)'{-noskin,-no-skin}'[don'\''t use any emulator skin]' \ '(-noskin -no-skin)'{-noskin,-no-skin}'[don'\''t use any emulator skin]' \
@ -108,7 +112,21 @@ _arguments \
'-memcheck[enable memory access checking]:flags' \ '-memcheck[enable memory access checking]:flags' \
'-qemu[pass arguments to qemu]:arguments' \ '-qemu[pass arguments to qemu]:arguments' \
'-verbose[same as '\''-debug-init'\'']' \ '-verbose[same as '\''-debug-init'\'']' \
'*'{-debug,-debug-,-debug-no-}'[enable/disable specific debug messages]:tag' '*'{-debug,-debug-,-debug-no-}'[enable/disable specific debug messages]:tag' \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
local -a _avds=($(_list_avds))
for ((i=1; i<=${#_avds[@]}; i++)); do
_avds[i]="@${_avds[i]}"
done
_values 'avds' "${_avds[@]}"
;;
esac
return ret
# Local Variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script