From 2d245b6bc5655df54a3934f1ebef286460d2d358 Mon Sep 17 00:00:00 2001 From: TimofeyTitovets Date: Sun, 27 Apr 2014 23:46:58 +0300 Subject: [PATCH] init simple completion for fastboot --- src/_fastboot | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 src/_fastboot diff --git a/src/_fastboot b/src/_fastboot new file mode 100644 index 0000000..34b980b --- /dev/null +++ b/src/_fastboot @@ -0,0 +1,116 @@ +#compdef fastboot +# ------------------------------------------------------------------------------ +# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the zsh-users nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for fastboot +# TODO: Add options handler +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Timofey Titovets +# +# ------------------------------------------------------------------------------ +_fastboot(){ + local -a command + command=( + 'update: reflash device from update.zip' + 'flashall:flash boot + recovery + system' + 'flash: [ ] write a file to a flash partition' + 'erase: erase a flash partition' + 'format: format a flash partition' + 'getvar: display a bootloader variable' + 'boot: [ ] download and boot kernel' + 'flash:raw boot [ ] create bootimage and flash it' + 'devices:list all connected devices' + 'continue:continue with autoboot' + 'reboot:reboot device normally' + 'reboot-bootloader:reboot device into bootloader' + 'help:show help' + ) + + local -a partition + partition=(boot recovery system) + +# local -a options +# options=( +# $command +# '-w:erase userdata and cache (and format if supported by partition type)' +# '-u:do not first erase partition before formatting' +# '-s: specify device serial number' +# '-l:with "devices", lists device paths' +# '-p: specify product name' +# '-c: override kernel commandline' +# '-i: specify a custom USB vendor id' +# '-b: specify a custom kernel base address. default: 0x10000000' +# '-n: specify the nand page size. default: 2048' +# '-S:[K|M|G] automatically sparse files greater than size. 0 to disable' +# ) + + local context state line expl + local -A opt_args + + _arguments '*:: :->subcmds' && return 0 + +# if (( CURRENT == 1 )); then +# _describe -t commands "fastboot commands" options -V1 +# return +# fi + + if (( CURRENT == 1 )); then + _describe -t commands "fastboot commands" command -V1 + return + fi + + case $words[1] in + update) + _arguments \ + '1: :_files -/' + ;; + flash) + _arguments \ + '1: :($partition)' \ + '2: :_files -/' + ;; + erase) + _arguments \ + '1: :($partition)' + ;; + format) + _arguments \ + '1: :($partition)' + ;; + boot) + _arguments \ + '1: :_files -/' + ;; + esac +} + +_fastboot "$@"