yay/completions/bash
Joey Holtzman 04c76a404e
feat(install): add --keepsrc to keep pkg/ and src/ directories (#2272)
* feat(install): add --nocleanbuild to keep pkg/ and src/ directories for
AUR packages

Providing this flag during installation of AUR packages allows for keeping
the src/ and pkg/ directories produced my makepkg. If the user wants to
delete the directories, they can either select to cleanBuild in the
cleanmenu or run the installation without the --nocleanbuild flag (yay
will only remove the directories if the package is rebuilt)

* fix(completion): simplify description for --nocleanbuild in fish

This makes the description consistent with the descriptions in the
man page, --help, and zsh completion.

* refactor(install): Rename --nocleanbuild to --keepsrc

This naming scheme is more familiar to users since it is the name of the
flag in Paru.

---------

Co-authored-by: jguer <me@jguer.space>
2023-09-18 09:21:42 +02:00

139 lines
4.2 KiB
Bash

# This file is in the public domain.
_arch_compgen() {
local i r
COMPREPLY=($(compgen -W '$*' -- "$cur"))
for ((i = 1; i < ${#COMP_WORDS[@]} - 1; i++)); do
for r in ${!COMPREPLY[@]}; do
if [[ ${COMP_WORDS[i]} == ${COMPREPLY[r]} ]]; then
unset 'COMPREPLY[r]'
break
fi
done
done
}
_arch_ptr2comp() {
local list= x y
for x; do
for y in '0 --' '1 -'; do
eval 'set -- ${'$x'[${y% *}]}'
list+=\ ${@/#/${y#* }}
done
done
_arch_compgen $list
}
_arch_incomp() {
local r="[[:space:]]-(-${1#* }[[:space:]]|[[:alnum:]_]*${1% *})"
[[ $COMP_LINE =~ $r ]]
}
_pacman_pkg() {
_arch_compgen "$(
if [[ $2 ]]; then
\pacman -$1 2>/dev/null | \cut -d' ' -f1 | \sort -u
else
\pacman -$1 2>/dev/null
fi
)"
}
_yay_pkg() {
[ -z "$cur" ] && _pacman_pkg Slq && return
_arch_compgen "$(yay -Pc)"
}
_pacman_repo_list() {
_arch_compgen "$(pacman-conf --repo-list)"
}
_yay() {
compopt -o default
local common core cur database files prev query remove sync upgrade o
local yays show getpkgbuild web
local cur prev words cword
_init_completion || return
database=('asdeps asexplicit')
files=('list machinereadable refresh regex' 'l x y')
query=('changelog check deps explicit file foreign groups info list native owns
search unrequired upgrades' 'c e g i k l m n o p s t u')
remove=('cascade dbonly nodeps assume-installed nosave print recursive unneeded' 'c n p s u')
sync=('asdeps asexplicit clean dbonly downloadonly overwrite groups ignore ignoregroup
info list needed nodeps assume-installed print refresh recursive search sysupgrade'
'c g i l p s u w y')
upgrade=('asdeps asexplicit overwrite needed nodeps assume-installed print recursive' 'p')
core=('database files help query remove sync upgrade version' 'D F Q R S U V h')
##yay stuff
common=('arch cachedir color config confirm dbpath debug gpgdir help hookdir logfile
noconfirm noprogressbar noscriptlet quiet root verbose
makepkg pacman git gpg gpgflags config requestsplitn sudoloop nosudoloop
redownload noredownload redownloadall rebuild rebuildall rebuildtree norebuild sortby
singlelineresults doublelineresults answerclean answerdiff answeredit answerupgrade noanswerclean noanswerdiff
noansweredit noanswerupgrade cleanmenu diffmenu editmenu cleanafter nocleanafter keepsrc
nocleanmenu nodiffmenu provides noprovides pgpfetch nopgpfetch
useask nouseask combinedupgrade nocombinedupgrade aur repo makepkgconf
nomakepkgconf askremovemake askyesremovemake removemake noremovemake completioninterval aururl aurrpcurl
searchby batchinstall nobatchinstall'
'b d h q r v')
yays=('clean gendb' 'c')
show=('complete defaultconfig currentconfig stats news' 'c d g s w')
getpkgbuild=('force print' 'f p')
web=('vote unvote' 'v u')
for o in 'D database' 'F files' 'Q query' 'R remove' 'S sync' 'U upgrade' 'Y yays' 'P show' 'G getpkgbuild' 'W web'; do
_arch_incomp "$o" && break
done
if [[ $? != 0 ]]; then
_arch_ptr2comp core
elif [[ ! $prev =~ ^-[[:alnum:]_]*[Vbhr] && ! $prev == --@(cachedir|color|config|dbpath|help|hookdir|gpgdir|logfile|root|version) ]]; then
[[ $cur == -* ]] && _arch_ptr2comp ${o#* } common ||
case ${o% *} in
D | R)
_pacman_pkg Qq
;;
F)
{ _arch_incomp 'l list' && _pacman_pkg Slq; } ||
_arch_incomp 'o owns' ||
compopt +o default
;;
Q)
{ _arch_incomp 'g groups' && _pacman_pkg Qg sort; } ||
{ _arch_incomp 'p file' && _pacman_file; } ||
{ _arch_incomp 's search' && compopt +o default; } ||
{ _arch_incomp 'u upgrades' && compopt +o default; } ||
_arch_incomp 'o owns' ||
_pacman_pkg Qq
;;
S)
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
{ _arch_incomp 'l list' && _pacman_repo_list; } ||
{ _arch_incomp 's search' && compopt +o default; } ||
_yay_pkg
;;
U)
_pacman_file
;;
G)
_yay_pkg
;;
W)
_yay_pkg
;;
esac
fi
true
}
_pacman_file() {
compopt -o filenames
_filedir 'pkg.*'
}
complete -F _yay yay
# ex:et ts=2 sw=2 ft=sh