3 # bash-completion - part of the FDroid server tools
4 # Commits updates to apps, allowing you to edit the commit messages
6 # Copyright (C) 2013 Daniel Martà <mvdan@mvdan.cc>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # 'fdroid' is aliased automatically, but aliases to it are not. For instance,
22 # to alias 'fd' to 'fdroid' and have competion available:
25 # complete -F _fdroid fd
27 # One can use completion on aliased subcommands as follows:
29 # alias fbuild='fdroid build'
30 # complete -F _fdroid_build fbuild
34 cur="${COMP_WORDS[COMP_CWORD]}"
35 prev="${COMP_WORDS[COMP_CWORD-1]}"
37 (( $# >= 1 )) && __complete_${1}
41 files=( metadata/*.txt )
42 files=( ${files[@]#metadata/} )
43 files=${files[@]%.txt}
44 COMPREPLY=( $( compgen -W "$files" -- $cur ) )
49 [ -f "${files[0]}" ] || return
51 files=( ${files[@]#*/} )
53 COMPREPLY=( $( compgen -W "$files" -- $cur ) )
60 files=( ${1}/${p}_*.apk )
61 [ -f "${files[0]}" ] || return
63 files=( ${files[@]#*_} )
64 files=${files[@]%.apk}
65 COMPREPLY=( $( compgen -P "${p}:" -W "$files" -- $cur ) )
72 COMPREPLY=( $( compgen -P "${p}:" -W "$( while read line; do
73 if [[ "$line" == "Build Version:"* ]]
77 elif [[ "$line" == "Build:"* ]]
82 done < "metadata/${p}.txt" )" -- $cur ) )
85 __complete_options() {
88 COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
91 COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
97 opts="-h -v -c -l -s -t -f"
98 lopts="--help --verbose --latest --server --resetserver --on-server
113 __complete_install() {
115 lopts="--help --verbose --all"
129 __complete_update() {
130 opts="-h -c -v -q -b -i -I -e -w"
131 lopts="--help --createmeta --verbose --quiet --buildreport --interactive
132 --icons --editor --wiki --pretty --clean"
141 __complete_publish() {
143 lopts="--help --verbose"
149 __apk_vercode unsigned
152 __apk_package unsigned
157 __complete_checkupdates() {
159 lopts="--help --verbose --auto --autoonly --commit --gplay"
170 __complete_import() {
172 lopts="--help --url --subdir --repo"
174 -u|--url|-r|--repo) return 0;;
182 __complete_rewritemeta() {
184 lopts="--help --verbose"
195 __complete_scanner() {
197 lopts="--help --verbose --nosvn"
211 __complete_verify() {
213 lopts="--help --verbose"
229 lopts="--help --verbose --download"
233 __complete_server() {
235 lopts="--help --verbose update"
241 lopts="--help --verbose --keystore --distinguished-name --repo-keyalias"
246 local cmd cmds aliased
248 cmds=" build init install update publish checkupdates import
249 rewritemeta scanner verify stats server "
252 for c in $cmds; do eval "_fdroid_${c} () {
253 local cur prev cmds opts lopts
257 [[ $cmds == *\ $cmd\ * ]] && _fdroid_${cmd} || {
258 (($COMP_CWORD == 1)) && COMPREPLY=( $( compgen -W "${cmds}" -- $cmd ) )
266 complete -F _fdroid fdroid
267 complete -F _fd-commit fd-commit