aboutsummaryrefslogtreecommitdiffstats
path: root/src/_emulator
diff options
context:
space:
mode:
authorNate Fischer <ntfschr@google.com>2020-03-26 16:08:12 -0700
committerNate Fischer <ntfschr@google.com>2020-03-28 13:34:20 -0700
commit99780ec53d75c1449fc320bece416eb92bc129ee (patch)
tree7ade3dc3be5a7f9377bfc81e9523387f69feb7ed /src/_emulator
parentMerge pull request #694 from syohex/syohex/yarn-add-file-completion (diff)
downloadzsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar.gz
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar.bz2
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar.lz
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar.xz
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.tar.zst
zsh-completions-99780ec53d75c1449fc320bece416eb92bc129ee.zip
Add avd completion to _emulator
This resolves a TODO in _emulator by adding completion for AVD names. This adds completion for "-avd" as well as the special "@AVD_NAME" syntax for non-option arguments.
Diffstat (limited to 'src/_emulator')
-rw-r--r--src/_emulator24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/_emulator b/src/_emulator
index 813dc2e..265dccd 100644
--- a/src/_emulator
+++ b/src/_emulator
@@ -18,11 +18,15 @@
typeset -A opt_args
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 skin options are contextual to -skindir value
# TODO snapshot options are mutually exclusive
# TODO Use '-snapshot-list' output for snapshot names
-# TODO Complete -avd with avd names ?
# TODO -logcat: use completer from _adb
# TODO Complete options with device values
# TODO Complete -prop
@@ -62,7 +66,7 @@ _arguments \
'-snapshot-list[show a list of available snapshots]' \
'-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)]' \
- '-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 -/' \
'-skin[select a given skin]' \
'(-noskin -no-skin)'{-noskin,-no-skin}'[don'\''t use any emulator skin]' \
@@ -108,7 +112,21 @@ _arguments \
'-memcheck[enable memory access checking]:flags' \
'-qemu[pass arguments to qemu]:arguments' \
'-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:
# mode: Shell-Script