2017-02-28 14:46:37 +01:00
|
|
|
# fdroid(1) completion -*- shell-script -*-
|
2013-07-14 19:09:31 +02:00
|
|
|
#
|
2013-12-30 17:15:27 +01:00
|
|
|
# bash-completion - part of the FDroid server tools
|
2013-07-14 19:09:31 +02:00
|
|
|
#
|
2017-02-28 14:46:37 +01:00
|
|
|
# Copyright (C) 2013-2017 Hans-Christoph Steiner <hans@eds.org>
|
2014-01-10 13:09:54 +01:00
|
|
|
# Copyright (C) 2013, 2014 Daniel Martí <mvdan@mvdan.cc>
|
2013-12-30 17:15:27 +01:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2013-07-14 19:09:31 +02:00
|
|
|
__fdroid_init() {
|
2013-10-29 00:19:33 +01:00
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
2013-07-14 19:09:31 +02:00
|
|
|
|
2013-10-29 00:19:33 +01:00
|
|
|
(( $# >= 1 )) && __complete_${1}
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2020-05-25 21:47:49 +02:00
|
|
|
__get_appid() {
|
|
|
|
files=( metadata/*.yml )
|
2013-12-11 17:29:38 +01:00
|
|
|
files=( ${files[@]#metadata/} )
|
2020-05-25 21:47:49 +02:00
|
|
|
files=${files[@]%.yml}
|
2015-10-04 12:08:28 +02:00
|
|
|
echo "$files"
|
|
|
|
}
|
|
|
|
|
|
|
|
__package() {
|
2020-05-25 21:47:49 +02:00
|
|
|
files="$(__get_appid)"
|
2013-11-18 15:26:57 +01:00
|
|
|
COMPREPLY=( $( compgen -W "$files" -- $cur ) )
|
|
|
|
}
|
|
|
|
|
2013-12-19 22:55:17 +01:00
|
|
|
__apk_package() {
|
|
|
|
files=( ${1}/*.apk )
|
|
|
|
[ -f "${files[0]}" ] || return
|
|
|
|
|
|
|
|
files=( ${files[@]#*/} )
|
2013-12-11 17:29:38 +01:00
|
|
|
files=${files[@]%_*}
|
|
|
|
COMPREPLY=( $( compgen -W "$files" -- $cur ) )
|
|
|
|
}
|
|
|
|
|
2013-12-19 22:55:17 +01:00
|
|
|
__apk_vercode() {
|
2013-12-31 10:17:49 +01:00
|
|
|
local p=${cur:0:-1}
|
2013-12-11 18:35:58 +01:00
|
|
|
|
2013-12-19 22:55:17 +01:00
|
|
|
files=( ${1}/${p}_*.apk )
|
|
|
|
[ -f "${files[0]}" ] || return
|
|
|
|
|
2013-12-11 18:35:58 +01:00
|
|
|
files=( ${files[@]#*_} )
|
|
|
|
files=${files[@]%.apk}
|
|
|
|
COMPREPLY=( $( compgen -P "${p}:" -W "$files" -- $cur ) )
|
|
|
|
}
|
|
|
|
|
2013-07-14 19:09:31 +02:00
|
|
|
__vercode() {
|
2020-05-25 21:44:19 +02:00
|
|
|
if [ $prev = ":" ]; then
|
|
|
|
appid="${COMP_WORDS[COMP_CWORD-2]}"
|
|
|
|
elif [ $cur = ":" ]; then
|
|
|
|
appid=$prev
|
|
|
|
cur=""
|
|
|
|
fi
|
|
|
|
versionCodes=`sed -En 's,^ +versionCode: +([0-9]+) *$,\1,p' metadata/${appid}.yml`
|
|
|
|
COMPREPLY=( $( compgen -W "$versionCodes" -- $cur ) )
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__complete_options() {
|
2013-10-29 00:19:33 +01:00
|
|
|
case "${cur}" in
|
|
|
|
--*)
|
2015-09-01 11:23:23 +02:00
|
|
|
COMPREPLY=( $( compgen -W "--help --version ${lopts}" -- $cur ) )
|
2013-10-29 00:19:33 +01:00
|
|
|
return 0;;
|
|
|
|
*)
|
2015-09-01 11:23:23 +02:00
|
|
|
COMPREPLY=( $( compgen -W "-h ${opts} --help --version ${lopts}" -- $cur ) )
|
2013-10-29 00:19:33 +01:00
|
|
|
return 0;;
|
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__complete_build() {
|
2020-10-06 11:39:46 +02:00
|
|
|
opts="-v -q -l -s -t -f -a"
|
2014-04-29 09:28:44 +02:00
|
|
|
|
2020-10-06 11:39:46 +02:00
|
|
|
lopts="--verbose --quiet --latest --stop --test --server --reset-server --skip-scan --scan-binary --no-tarball --force --all --no-refresh"
|
2020-05-25 21:44:19 +02:00
|
|
|
case "${prev}" in
|
|
|
|
:)
|
|
|
|
__vercode
|
|
|
|
return 0;;
|
|
|
|
esac
|
2013-12-11 17:29:38 +01:00
|
|
|
case "${cur}" in
|
2013-12-19 23:06:57 +01:00
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
2020-05-25 21:44:19 +02:00
|
|
|
:)
|
2013-10-29 00:19:33 +01:00
|
|
|
__vercode
|
|
|
|
return 0;;
|
2013-12-11 17:29:38 +01:00
|
|
|
*)
|
|
|
|
__package
|
|
|
|
return 0;;
|
2013-10-29 00:19:33 +01:00
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2017-09-13 09:53:26 +02:00
|
|
|
__complete_gpgsign() {
|
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose --quiet"
|
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2013-12-11 18:35:58 +01:00
|
|
|
__complete_install() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose --quiet --all"
|
2013-12-11 18:35:58 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*:)
|
2013-12-19 22:55:17 +01:00
|
|
|
__apk_vercode repo
|
2013-12-11 18:35:58 +01:00
|
|
|
return 0;;
|
|
|
|
*)
|
2013-12-19 22:55:17 +01:00
|
|
|
__apk_package repo
|
2013-12-11 18:35:58 +01:00
|
|
|
return 0;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2013-07-14 19:09:31 +02:00
|
|
|
__complete_update() {
|
2020-10-06 11:39:46 +02:00
|
|
|
opts="-c -v -q -i -I -e"
|
2020-10-06 11:31:22 +02:00
|
|
|
lopts="--create-metadata --verbose --quiet
|
2020-10-06 11:39:46 +02:00
|
|
|
--icons --pretty --clean --delete-unknown
|
2017-05-31 21:20:35 +02:00
|
|
|
--nosign --rename-apks --use-date-from-apk"
|
2013-10-29 00:19:33 +01:00
|
|
|
case "${prev}" in
|
|
|
|
-e|--editor)
|
|
|
|
_filedir
|
|
|
|
return 0;;
|
|
|
|
esac
|
|
|
|
__complete_options
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__complete_publish() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose --quiet"
|
2013-12-19 22:55:17 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*:)
|
|
|
|
__apk_vercode unsigned
|
|
|
|
return 0;;
|
|
|
|
*)
|
|
|
|
__apk_package unsigned
|
2013-10-29 00:19:33 +01:00
|
|
|
return 0;;
|
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__complete_checkupdates() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
2018-03-05 21:44:38 +01:00
|
|
|
lopts="--verbose --quiet --auto --autoonly --commit --gplay --allow-dirty"
|
2013-12-11 19:37:38 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*)
|
2013-10-29 00:19:33 +01:00
|
|
|
__package
|
|
|
|
return 0;;
|
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__complete_import() {
|
2018-10-11 12:02:22 +02:00
|
|
|
opts="-c -h -l -q -s -u -v -W"
|
|
|
|
lopts="--categories --license --quiet --rev --subdir --url"
|
2013-10-29 00:19:33 +01:00
|
|
|
case "${prev}" in
|
2018-10-11 12:02:22 +02:00
|
|
|
-c|-l|-s|-u|--categories|--license|--quiet|--rev|--subdir|--url)
|
|
|
|
return 0;;
|
|
|
|
-W)
|
|
|
|
COMPREPLY=( $( compgen -W "error warn ignore" -- $cur ) )
|
|
|
|
return 0;;
|
2013-10-29 00:19:33 +01:00
|
|
|
esac
|
|
|
|
__complete_options
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2014-02-05 09:21:28 +01:00
|
|
|
__complete_readmeta() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose --quiet"
|
2014-02-15 00:00:05 +01:00
|
|
|
__complete_options
|
2014-02-05 09:21:28 +01:00
|
|
|
}
|
|
|
|
|
2013-07-14 19:09:31 +02:00
|
|
|
__complete_rewritemeta() {
|
2015-09-25 07:40:49 +02:00
|
|
|
opts="-v -q -l"
|
|
|
|
lopts="--verbose --quiet --list"
|
2013-12-19 22:59:32 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*)
|
2013-10-29 00:19:33 +01:00
|
|
|
__package
|
|
|
|
return 0;;
|
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2014-01-03 00:12:42 +01:00
|
|
|
__complete_lint() {
|
2020-06-02 21:52:58 +02:00
|
|
|
opts="-v -q -f"
|
|
|
|
lopts="--verbose --quiet --force-yamllint --format"
|
2014-01-03 00:12:42 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*)
|
|
|
|
__package
|
|
|
|
return 0;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2013-07-14 19:09:31 +02:00
|
|
|
__complete_scanner() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
2015-01-11 14:22:30 +01:00
|
|
|
lopts="--verbose --quiet"
|
2013-12-19 23:06:57 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*:)
|
|
|
|
__vercode
|
|
|
|
return 0;;
|
|
|
|
*)
|
2013-10-29 00:19:33 +01:00
|
|
|
__package
|
|
|
|
return 0;;
|
|
|
|
esac
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2013-08-29 15:26:24 +02:00
|
|
|
__complete_verify() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q -p"
|
|
|
|
lopts="--verbose --quiet"
|
2013-12-19 23:14:22 +01:00
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
*:)
|
|
|
|
__vercode
|
|
|
|
return 0;;
|
|
|
|
*)
|
2013-10-29 00:19:33 +01:00
|
|
|
__package
|
|
|
|
return 0;;
|
|
|
|
esac
|
2013-08-29 15:26:24 +02:00
|
|
|
}
|
|
|
|
|
2017-03-27 21:52:15 +02:00
|
|
|
__complete_btlog() {
|
|
|
|
opts="-u"
|
|
|
|
lopts="--git-remote --git-repo --url"
|
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2017-11-29 12:40:04 +01:00
|
|
|
__complete_mirror() {
|
|
|
|
opts="-v"
|
2020-01-14 15:12:21 +01:00
|
|
|
lopts="--all --archive --build-logs --pgp-signatures --src-tarballs --output-dir"
|
2017-11-29 12:40:04 +01:00
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2017-11-22 23:27:07 +01:00
|
|
|
__complete_nightly() {
|
|
|
|
opts="-v -q"
|
2019-05-02 08:51:39 +02:00
|
|
|
lopts="--show-secret-var --archive-older"
|
2017-11-22 23:27:07 +01:00
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2018-02-13 12:54:48 +01:00
|
|
|
__complete_deploy() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-i -v -q"
|
2015-01-11 14:24:45 +01:00
|
|
|
lopts="--identity-file --local-copy-dir --sync-from-local-copy-dir
|
2019-05-02 08:51:39 +02:00
|
|
|
--verbose --quiet --no-checksum --no-keep-git-mirror-archive"
|
2013-10-29 00:19:33 +01:00
|
|
|
__complete_options
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
2017-09-13 09:53:26 +02:00
|
|
|
__complete_signatures() {
|
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose --no-check-https"
|
|
|
|
case "${cur}" in
|
|
|
|
-*)
|
|
|
|
__complete_options
|
|
|
|
return 0;;
|
|
|
|
esac
|
2021-04-08 12:41:48 +02:00
|
|
|
_filedir 'apk'
|
|
|
|
return 0
|
2017-09-13 09:53:26 +02:00
|
|
|
}
|
|
|
|
|
2015-01-11 14:16:57 +01:00
|
|
|
__complete_signindex() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q"
|
|
|
|
lopts="--verbose"
|
2015-01-11 14:16:57 +01:00
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2013-11-04 20:28:32 +01:00
|
|
|
__complete_init() {
|
2015-01-11 14:19:31 +01:00
|
|
|
opts="-v -q -d"
|
|
|
|
lopts="--verbose --quiet --distinguished-name --keystore
|
2014-06-12 21:51:33 +02:00
|
|
|
--repo-keyalias --android-home --no-prompt"
|
2013-11-04 20:28:32 +01:00
|
|
|
__complete_options
|
|
|
|
}
|
|
|
|
|
2017-09-13 14:02:04 +02:00
|
|
|
__cmds=" \
|
|
|
|
btlog \
|
|
|
|
build \
|
|
|
|
checkupdates \
|
2018-02-13 12:54:48 +01:00
|
|
|
deploy \
|
2017-09-13 14:02:04 +02:00
|
|
|
gpgsign \
|
|
|
|
import \
|
|
|
|
init \
|
|
|
|
install \
|
|
|
|
lint \
|
2017-11-29 12:40:04 +01:00
|
|
|
mirror \
|
2017-11-22 23:27:07 +01:00
|
|
|
nightly \
|
2017-09-13 14:02:04 +02:00
|
|
|
publish \
|
|
|
|
readmeta \
|
|
|
|
rewritemeta \
|
|
|
|
scanner \
|
|
|
|
signatures \
|
|
|
|
signindex \
|
|
|
|
update \
|
|
|
|
verify \
|
2017-09-13 09:53:26 +02:00
|
|
|
"
|
2013-07-14 19:09:31 +02:00
|
|
|
|
2015-09-03 06:23:08 +02:00
|
|
|
for c in $__cmds; do
|
|
|
|
eval "_fdroid_${c} () {
|
2013-12-31 10:17:49 +01:00
|
|
|
local cur prev opts lopts
|
2015-09-03 06:23:08 +02:00
|
|
|
__fdroid_init ${c}
|
|
|
|
}"
|
|
|
|
done
|
|
|
|
|
|
|
|
_fdroid() {
|
|
|
|
local cmd
|
|
|
|
cmd=${COMP_WORDS[1]}
|
2013-07-14 19:09:31 +02:00
|
|
|
|
2015-09-03 06:23:08 +02:00
|
|
|
[[ $__cmds == *\ $cmd\ * ]] && _fdroid_${cmd} || {
|
|
|
|
(($COMP_CWORD == 1)) && COMPREPLY=( $( compgen -W "${__cmds}" -- $cmd ) )
|
2013-10-29 00:19:33 +01:00
|
|
|
}
|
2013-07-14 19:09:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _fdroid fdroid
|
|
|
|
|
|
|
|
return 0
|