3 # fdroid completion support.
5 # 'fdroid' is aliased automatically, but aliases to it are not. For instance,
6 # to alias 'fd' to 'fdroid' and have competion available:
9 # complete -F _fdroid fd
11 # One can use completion on aliased subcommands as follows:
13 # alias fbuild='fdroid build'
14 # complete -F _fdroid_build fbuild
18 cur="${COMP_WORDS[COMP_CWORD]}"
19 prev="${COMP_WORDS[COMP_CWORD-1]}"
21 (( $# >= 1 )) && __complete_${1}
25 files=( metadata/*.txt )
26 files=( ${files[@]#metadata/} )
27 files=${files[@]%.txt}
28 COMPREPLY=( $( compgen -W "$files" -- $cur ) )
33 [ -f "${files[0]}" ] || return
35 files=( ${files[@]#*/} )
37 COMPREPLY=( $( compgen -W "$files" -- $cur ) )
44 files=( ${1}/${p}_*.apk )
45 [ -f "${files[0]}" ] || return
47 files=( ${files[@]#*_} )
48 files=${files[@]%.apk}
49 COMPREPLY=( $( compgen -P "${p}:" -W "$files" -- $cur ) )
56 COMPREPLY=( $( compgen -P "${p}:" -W "$( while read line; do
57 if [[ "$line" == "Build Version:"* ]]
61 elif [[ "$line" == "Build:"* ]]
66 done < "metadata/${p}.txt" )" -- $cur ) )
69 __complete_options() {
72 COMPREPLY=( $( compgen -W "${lopts}" -- $cur ) )
75 COMPREPLY=( $( compgen -W "${opts} ${lopts}" -- $cur ) )
81 opts="-h -v -c -l -s -t -f"
82 lopts="--help --verbose --latest --server --resetserver --on-server
97 __complete_install() {
99 lopts="--help --verbose --all"
113 __complete_update() {
114 opts="-h -c -v -q -b -i -I -e -w"
115 lopts="--help --createmeta --verbose --quiet --buildreport --interactive
116 --icons --editor --wiki --pretty --clean"
125 __complete_publish() {
127 lopts="--help --verbose"
133 __apk_vercode unsigned
136 __apk_package unsigned
141 __complete_checkupdates() {
143 lopts="--help --verbose --auto --autoonly --commit --gplay"
154 __complete_import() {
156 lopts="--help --url --subdir --repo"
158 -u|--url|-r|--repo) return 0;;
166 __complete_rewritemeta() {
168 lopts="--help --verbose"
179 __complete_scanner() {
181 lopts="--help --verbose --nosvn"
195 __complete_verify() {
197 lopts="--help --verbose --package"
208 lopts="--help --verbose --download"
212 __complete_server() {
214 lopts="--help --verbose update"
220 lopts="--help --verbose --keystore --distinguished-name --repo-keyalias"
225 local cmd cmds aliased
227 cmds=" build init install update publish checkupdates import
228 rewritemeta scanner verify stats server "
231 for c in $cmds; do eval "_fdroid_${c} () {
232 local cur prev cmds opts lopts
236 [[ $cmds == *\ $cmd\ * ]] && _fdroid_${cmd} || {
237 (($COMP_CWORD == 1)) && COMPREPLY=( $( compgen -W "${cmds}" -- $cmd ) )
245 complete -F _fdroid fdroid
246 complete -F _fd-commit fd-commit