forked from Mirrors/flatpak-builder
completion: Update to the new cli commands
parent
5a12157add
commit
7fb1309488
|
@ -18,30 +18,35 @@ _xdg-app() {
|
|||
prev=${COMP_WORDS[COMP_CWORD-2]}
|
||||
fi
|
||||
|
||||
local i verb comps mode
|
||||
local i verb comps mode kind bundle
|
||||
local remote name
|
||||
local file dir cmd sdk loc
|
||||
|
||||
local -A VERBS=(
|
||||
[ALL]='add-remote modify-remote delete-remote ls-remote list-remotes install-runtime update-runtime uninstall-runtime list-runtimes install-app update-app uninstall-app install-bundle list-apps run override enter export-file build-init build build-finish build-export build-bundle repo-update make-app-current'
|
||||
[MODE]='add-remote modify-remote delete-remote ls-remote list-remotes install-runtime update-runtime uninstall-runtime list-runtimes install-app update-app uninstall-app install-bundle list-apps make-app-current'
|
||||
[ALL]='remote-add remote-modify remote-delete remote-ls remote-list install update uninstall list run override enter export-file build-init build build-finish build-export build-bundle build-update-repo make-current'
|
||||
[MODE]='remote-add remote-modify remote-delete remote-ls remote-list install update uninstall list list make-current'
|
||||
[KIND]='install update uninstall list remote-ls'
|
||||
[PERMS]='run override build build-finish'
|
||||
[UNINSTALL]='uninstall-runtime uninstall-app'
|
||||
[ARCH]='build-init install-runtime build-bundle install-app run uninstall-runtime uninstall-app update-runtime update-app make-app-current'
|
||||
[USER_AND_SYSTEM]='run list-remotes list-apps list-runtimes'
|
||||
[UNINSTALL]='uninstall'
|
||||
[SHOW_DETAILS]='list remote-list remote-ls'
|
||||
[ARCH]='build-init install build-bundle run uninstall update make-current'
|
||||
[USER_AND_SYSTEM]='run remote-list list'
|
||||
[APP_AND_RUNTIME]='install update uninstall'
|
||||
)
|
||||
|
||||
local -A OPTS=(
|
||||
[GENERAL]='--help --verbose --version'
|
||||
[MODE]='--user --system'
|
||||
[KIND]='--app --runtime'
|
||||
[ARCH]='--arch='
|
||||
[SHOW_DETAILS]='-d --show-details'
|
||||
[PERMS]='--share= --unshare= --socket= --nosocket= --device= --nodevice= --filesystem= --env= --own-name= --talk-name= --persist='
|
||||
[ADD_REMOTE]='--no-gpg-verify --if-not-exists --title= --gpg-import= --gpg-key='
|
||||
[MODIFY_REMOTE]='--no-gpg-verify --gpg-verify --title= --gpg-import= --gpg-key='
|
||||
[LIST_REMOTES]='--show-details'
|
||||
[LS_REMOTE]='--show-details --runtimes --apps --updates'
|
||||
[LS_REMOTE]='--show-details --updates'
|
||||
[UNINSTALL]='--keep-ref --force-remove'
|
||||
[INSTALL_BUNDLE]='--gpg-file='
|
||||
[INSTALL]='--bundle --gpg-file='
|
||||
[BUILD_BUNDLE]='--gpg-keys= --runtime --arch= --repo-url='
|
||||
[RUN]='--command= --branch= --devel --runtime='
|
||||
[BUILD_INIT]='--arch= --var='
|
||||
|
@ -66,6 +71,12 @@ _xdg-app() {
|
|||
fi
|
||||
done
|
||||
|
||||
if __contains_word "--bundle" ${COMP_WORDS[*]}; then
|
||||
bundle="true"
|
||||
else
|
||||
bundle="false"
|
||||
fi
|
||||
|
||||
if __contains_word "--user" ${COMP_WORDS[*]}; then
|
||||
if __contains_word "--system" ${COMP_WORDS[*]}; then
|
||||
mode="--user --system"
|
||||
|
@ -84,6 +95,24 @@ _xdg-app() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if __contains_word "--app" ${COMP_WORDS[*]}; then
|
||||
if __contains_word "--runtime" ${COMP_WORDS[*]}; then
|
||||
kind="--app --runtime"
|
||||
else
|
||||
kind="--app"
|
||||
fi
|
||||
else
|
||||
if __contains_word "--runtime" ${COMP_WORDS[*]}; then
|
||||
kind="--runtime"
|
||||
else
|
||||
if __contains_word "$first_verb" ${VERBS[APP_AND_RUNTIME]}; then
|
||||
kind="--app --runtime"
|
||||
else
|
||||
kind="--app"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--arch)
|
||||
|
@ -92,8 +121,15 @@ _xdg-app() {
|
|||
--command)
|
||||
comps=$(compgen -A command)
|
||||
;;
|
||||
--var|--runtime)
|
||||
comps=$(xdg-app $mode list-runtimes)
|
||||
--var)
|
||||
comps=$(xdg-app $mode list --runtime)
|
||||
;;
|
||||
--runtime)
|
||||
if __contains_word "$verb" ${VERBS[KIND]}; then
|
||||
comps=XXX
|
||||
else
|
||||
comps=$(xdg-app $mode list --runtime)
|
||||
fi
|
||||
;;
|
||||
--share|--noshare)
|
||||
comps='network ipc'
|
||||
|
@ -111,8 +147,10 @@ _xdg-app() {
|
|||
comps='host home xdg-desktop xdg-documents xdg-download xdg-music xdg-pictures xdg-public-share xdg-templates xdg-videos'
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
if [[ $comps != "XXXX" ]] ; then
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
for ((i=0; i < COMP_CWORD; i++)); do
|
||||
|
@ -125,17 +163,17 @@ _xdg-app() {
|
|||
if __contains_word "${COMP_WORDS[i]}" ${VERBS[*]} &&
|
||||
test -z $verb; then
|
||||
verb=${COMP_WORDS[i]}
|
||||
elif [[ $verb = install-bundle ]]; then
|
||||
elif [[ $verb = install && $bundle = "true" ]]; then
|
||||
if [[ -z $file ]]; then
|
||||
file=${COMP_WORDS[i]}
|
||||
fi
|
||||
elif [[ $verb = install-* ]]; then
|
||||
elif [[ $verb = install ]]; then
|
||||
if [[ -z $remote ]]; then
|
||||
remote=${COMP_WORDS[i]}
|
||||
elif [[ -z $name ]]; then
|
||||
name=${COMP_WORDS[i]}
|
||||
fi
|
||||
elif [[ $verb =~ (update-*|uninstall-*|run) ]]; then
|
||||
elif [[ $verb =~ (update|uninstall|run) ]]; then
|
||||
if [[ -z $name ]]; then
|
||||
name=${COMP_WORDS[i]}
|
||||
fi
|
||||
|
@ -173,7 +211,7 @@ _xdg-app() {
|
|||
elif [[ -z $name ]]; then
|
||||
name=${COMP_WORDS[i]}
|
||||
fi
|
||||
elif [[ $verb = repo-update ]]; then
|
||||
elif [[ $verb = build-update-repo ]]; then
|
||||
if [[ -z $loc ]]; then
|
||||
loc=${COMP_WORDS[i]}
|
||||
fi
|
||||
|
@ -192,15 +230,21 @@ _xdg-app() {
|
|||
if __contains_word "$verb" ${VERBS[MODE]}; then
|
||||
comps="$comps ${OPTS[MODE]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[KIND]}; then
|
||||
comps="$comps ${OPTS[KIND]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[PERMS]}; then
|
||||
comps="$comps ${OPTS[PERMS]}"
|
||||
fi
|
||||
if [ "$verb" = "list-remotes" ]; then
|
||||
if [ "$verb" = "remote-list" ]; then
|
||||
comps="$comps ${OPTS[LIST_REMOTES]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[ARCH]}; then
|
||||
comps="$comps ${OPTS[ARCH]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[SHOW_DETAILS]}; then
|
||||
comps="$comps ${OPTS[SHOW_DETAILS]}"
|
||||
fi
|
||||
if __contains_word "$verb" ${VERBS[UNINSTALL]}; then
|
||||
comps="$comps ${OPTS[UNINSTALL]}"
|
||||
fi
|
||||
|
@ -210,7 +254,7 @@ _xdg-app() {
|
|||
if [ "$verb" = "export-file" ]; then
|
||||
comps="$comps ${OPTS[EXPORT_FILE]}"
|
||||
fi
|
||||
if [ "$verb" = "ls-remote" ]; then
|
||||
if [ "$verb" = "remote-ls" ]; then
|
||||
comps="$comps ${OPTS[LS_REMOTE]}"
|
||||
fi
|
||||
if [ "$verb" = "build-init" ]; then
|
||||
|
@ -225,8 +269,8 @@ _xdg-app() {
|
|||
if [ "$verb" = "build-bundle" ]; then
|
||||
comps="$comps ${OPTS[BUILD_BUNDLE]}"
|
||||
fi
|
||||
if [ "$verb" = "install-bundle" ]; then
|
||||
comps="$comps ${OPTS[INSTALL_BUNDLE]}"
|
||||
if [ "$verb" = "install" ]; then
|
||||
comps="$comps ${OPTS[INSTALL]}"
|
||||
fi
|
||||
if [ "$verb" = "build-export" ]; then
|
||||
comps="$comps ${OPTS[BUILD_EXPORT]}"
|
||||
|
@ -234,58 +278,48 @@ _xdg-app() {
|
|||
if [ "$verb" = "repo-update" ]; then
|
||||
comps="$comps ${OPTS[REPO_UPDATE]}"
|
||||
fi
|
||||
if [ "$verb" = "add-remote" ]; then
|
||||
if [ "$verb" = "remote-add" ]; then
|
||||
comps="$comps ${OPTS[ADD_REMOTE]}"
|
||||
fi
|
||||
if [ "$verb" = "modify-remote" ]; then
|
||||
if [ "$verb" = "remote-modify" ]; then
|
||||
comps="$comps ${OPTS[MODIFY_REMOTE]}"
|
||||
fi
|
||||
else
|
||||
case "$verb" in
|
||||
add-remote|modify-remote|delete-remote|ls-remote)
|
||||
remote-add|remote-modify|remote-delete|remote-ls)
|
||||
comps=$(xdg-app $mode list-remotes)
|
||||
;;
|
||||
|
||||
install-runtime)
|
||||
if [[ -z $remote ]]; then
|
||||
comps=$(xdg-app $mode list-remotes)
|
||||
elif [[ -z $name ]]; then
|
||||
comps=$(xdg-app $mode ls-remote $remote --runtimes)
|
||||
install)
|
||||
if [[ $bundle == "true" ]]; then
|
||||
comps=''
|
||||
compopt -o filenames
|
||||
else
|
||||
if [[ -z $remote ]]; then
|
||||
comps=$(xdg-app $mode remote-list)
|
||||
if [[ $mode == "--system" ]]; then
|
||||
comps="$comps --user"
|
||||
fi
|
||||
elif [[ -z $name ]]; then
|
||||
comps=$(xdg-app remote-ls $mode $kind $remote)
|
||||
else
|
||||
comps='' # FIXME: branches
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
list-remotes|list-runtimes|list-apps)
|
||||
remote-list|list)
|
||||
comps=''
|
||||
;;
|
||||
|
||||
update-runtime|uninstall-runtime)
|
||||
update|uninstall)
|
||||
if [[ -z $name ]]; then
|
||||
comps=$(xdg-app $mode list-runtimes)
|
||||
comps=$(xdg-app $mode $kind list)
|
||||
else
|
||||
comps='' # FIXME: branches
|
||||
fi
|
||||
;;
|
||||
|
||||
install-app)
|
||||
if [[ -z $remote ]]; then
|
||||
comps=$(xdg-app $mode list-remotes)
|
||||
elif [[ -z $name ]]; then
|
||||
comps=$(xdg-app $mode ls-remote $remote --apps)
|
||||
else
|
||||
comps='' # FIXME: branches
|
||||
fi
|
||||
;;
|
||||
|
||||
update-app|uninstall-app)
|
||||
if [[ -z $name ]]; then
|
||||
comps=$(xdg-app $mode list-apps)
|
||||
else
|
||||
comps='' # FIXME: branches
|
||||
fi
|
||||
;;
|
||||
|
||||
run|override)
|
||||
# run doesn't take --user or --system, so don't use mode here
|
||||
if [[ -z $name ]]; then
|
||||
|
@ -346,14 +380,7 @@ _xdg-app() {
|
|||
fi
|
||||
;;
|
||||
|
||||
install-bundle)
|
||||
if [[ -z $file ]]; then
|
||||
comps=''
|
||||
compopt -o filenames
|
||||
fi
|
||||
;;
|
||||
|
||||
repo-update)
|
||||
build-update-repo)
|
||||
if [[ -z $loc ]]; then
|
||||
comps=''
|
||||
compopt -o dirnames
|
||||
|
|
Loading…
Reference in New Issue