aboutsummaryrefslogtreecommitdiffstats
path: root/src/_avdmanager
diff options
context:
space:
mode:
authorShohei YOSHIDA <syohex@gmail.com>2023-01-06 22:21:37 +0900
committerShohei YOSHIDA <syohex@gmail.com>2023-01-06 23:28:55 +0900
commit8c6ffb73e9434b2cf14c46fede4488dbd577cdb0 (patch)
tree3c3b75f998591ea76fda58d22a5d6a3bd47d52f9 /src/_avdmanager
parentMerge pull request #976 from zsh-users/add-emacs-completions (diff)
downloadzsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar.gz
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar.bz2
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar.lz
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar.xz
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.tar.zst
zsh-completions-8c6ffb73e9434b2cf14c46fede4488dbd577cdb0.zip
Add avdmanager and sdkmanager completion
Diffstat (limited to 'src/_avdmanager')
-rw-r--r--src/_avdmanager197
1 files changed, 197 insertions, 0 deletions
diff --git a/src/_avdmanager b/src/_avdmanager
new file mode 100644
index 0000000..9b181d8
--- /dev/null
+++ b/src/_avdmanager
@@ -0,0 +1,197 @@
+#compdef avdmanager
+# ------------------------------------------------------------------------------
+# Copyright (c) 2023 Github zsh-users - https://github.com/zsh-users
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+# ------------------------------------------------------------------------------
+# Description
+# -----------
+#
+# Completion script for avdmanager(https://developer.android.com/studio/command-line/avdmanager)
+#
+# ------------------------------------------------------------------------------
+# Authors
+# -------
+#
+# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
+#
+# ------------------------------------------------------------------------------
+
+_avdmanager() {
+ typeset -A opt_args
+ local context state line
+ local curcontext="$curcontext"
+ local ret=1
+
+ _arguments -C -A "-*" \
+ '(- *)'{-h,--help}'[Print help message]' \
+ '(-s --silent)'{-s,--silent}'[Silent mode, shows error only]' \
+ '(-v --verbose)'{-v,--verbose}'[Verbose mode, shows errors, warnings and all messages]' \
+ '--clear-cache[Clear the SDK Manager repository manifest cache]' \
+ '1: :_avdmanager_subcommands' \
+ '*::arg:->args' \
+ && ret=0
+
+ case "$state" in
+ (args)
+ if (( $+functions[_avdmanager_${words[1]}] )); then
+ _avdmanager_${words[1]} && ret=0
+ else
+ ret=0
+ fi
+ ;;
+ esac
+
+ return ret
+}
+
+(( $+functions[_avdmanager_list] )) ||
+_avdmanager_list() {
+ local ret=1
+
+ _arguments -C \
+ '1: :(avd target device)' \
+ '*:: :->arg' \
+ && ret=0
+
+ case $state in
+ (arg)
+ case $words[1] in
+ (avd|target|device)
+ _arguments \
+ '(-0 --null)'{-0,--null}'[Terminate lines with \0 instead of \n]' \
+ '(-c --compact)'{-c,--compact}'[Compact output]' \
+ && ret=0
+ ;;
+ esac
+ ;;
+ esac
+
+ return $ret
+}
+
+(( $+functions[_avdmanager_create] )) ||
+_avdmanager_create() {
+ local ret=1
+
+ _arguments -C \
+ '1: :(avd)' \
+ '*:: :->arg' \
+ && ret=0
+
+ case $state in
+ (arg)
+ case $words[1] in
+ (avd)
+ _arguments \
+ '(-c --sdcard)'{-c,--sdcard}'[Path to a shared SD card image]: :_files' \
+ '(-g --tag)'{-g,--tag}'[The sys-img tag to use for the AVD]:tag' \
+ '(-p --path)'{-p,--path}'[Directory where the new AVD will be created]' \
+ '(-k --package)'{-k,--package}'[Package path of the system image for this AVD]:package' \
+ '(-n --name)'{-n,--name}'[Name of the new AVD]:name' \
+ '--skin[The optional name of a skin to use with this device]' \
+ '(-f --force)'{-f,--force}'[Forces creation]' \
+ '(-b --abi)'{-b,--abi}'[The ABI to use for the AVD]:abi' \
+ '(-d --device)'{-d,--device}'[The optional device definition to use]' \
+ && ret=0
+ ;;
+ esac
+ ;;
+ esac
+
+ return $ret
+}
+
+(( $+functions[_avdmanager_move] )) ||
+_avdmanager_move() {
+ local ret=1
+
+ _arguments -C \
+ '1: :(avd)' \
+ '*:: :->arg' \
+ && ret=0
+
+ case $state in
+ (arg)
+ case $words[1] in
+ (avd)
+ _arguments \
+ '(-p --path)'{-p,--path}"[Path to the AVD's new directory]: :_files -/" \
+ '(-n --name)'{-n,--name}'[Name of the AVD to delete]: :_avdmanager_avds' \
+ '(-r --rename)'{-r,--rename}'[New name of the AVD]' \
+ && ret=0
+ ;;
+ esac
+ ;;
+ esac
+
+ return $ret
+}
+
+(( $+functions[_avdmanager_delete] )) ||
+_avdmanager_delete() {
+ local ret=1
+
+ _arguments -C \
+ '1: :(avd)' \
+ '*:: :->arg' \
+ && ret=0
+
+ case $state in
+ (arg)
+ case $words[1] in
+ (avd)
+ _arguments \
+ '(-n --name)'{-n,--name}'[Name of the AVD to delete]: :_avdmanager_avds' \
+ && ret=0
+ ;;
+ esac
+ ;;
+ esac
+
+ return $ret
+}
+
+(( $+functions[_avdmanager_subcommands] )) ||
+_avdmanager_subcommands() {
+ local -a commands=(
+ "list:Lists existing targets or virtual devices"
+ "create:Creates a new Android Virtual Device"
+ "move:Moves or renames an Android Virtual Device"
+ "delete:Deletes an Android Virtual Device"
+ )
+ _describe -t commands 'subcommand' commands
+}
+
+(( $+functions[_avdmanager_avds] )) ||
+_avdmanager_avds() {
+ local -a avds=(${(@f)"$(avdmanager list avd -c)"})
+ _values 'android virtual devices' $avds
+}
+
+_avdmanager "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 2
+# indent-tabs-mode: nil
+# sh-basic-offset: 2
+# End:
+# vim: ft=zsh sw=2 ts=2 et