zsh_completion: add sogrep completions

Transform sogrep into an in-prog so we can benefit from the m4 macro
to specify valid repos in a single place of truth.

Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Levente Polyak 2019-09-13 01:32:57 +02:00
parent f32a264796
commit 64b7d99504
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
5 changed files with 49 additions and 10 deletions

1
.gitignore vendored
View File

@ -15,4 +15,5 @@ zsh_completion
find-libdeps find-libdeps
crossrepomove crossrepomove
arch-nspawn arch-nspawn
sogrep
doc/*.1 doc/*.1

View File

@ -16,12 +16,12 @@ IN_PROGS = \
crossrepomove\ crossrepomove\
arch-nspawn \ arch-nspawn \
mkarchroot \ mkarchroot \
makechrootpkg makechrootpkg \
sogrep
BINPROGS = \ BINPROGS = \
$(IN_PROGS) \ $(IN_PROGS) \
offload-build \ offload-build \
sogrep
CONFIGFILES = \ CONFIGFILES = \
makepkg-x86_64.conf \ makepkg-x86_64.conf \

31
lib/valid-repos.sh Normal file
View File

@ -0,0 +1,31 @@
#!/hint/bash
# License: Unspecified
:
# shellcheck disable=2034
_repos=(
staging
testing
core
extra
community-staging
community-testing
community
multilib-staging
multilib-testing
multilib
gnome-unstable
kde-unstable
)
# shellcheck disable=2034
_build_repos=(
staging
testing
extra
multilib-staging
multilib-testing
multilib
gnome-unstable
kde-unstable
)

View File

@ -21,10 +21,8 @@
# globals # globals
: ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"} : ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"}
: ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"} : ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"}
repos=('staging' 'testing' 'core' 'extra'
'community-staging' 'community-testing' 'community' m4_include(lib/valid-repos.sh)
'multilib-staging' 'multilib-testing' 'multilib'
'gnome-unstable' 'kde-unstable')
arches=('x86_64') arches=('x86_64')
# options # options
@ -39,7 +37,7 @@ recache() {
(( VERBOSE )) && verbosity=--progress-bar (( VERBOSE )) && verbosity=--progress-bar
for repo in "${repos[@]}"; do for repo in "${_repos[@]}"; do
for arch in "${arches[@]}"; do for arch in "${arches[@]}"; do
rm -rf "${SOCACHE_DIR}/${arch}/${repo}" rm -rf "${SOCACHE_DIR}/${arch}/${repo}"
mkdir -p "${SOCACHE_DIR}/${arch}/${repo}" mkdir -p "${SOCACHE_DIR}/${arch}/${repo}"
@ -49,10 +47,10 @@ recache() {
} }
search() { search() {
local repo=$1 arch lib=$2 srepos=("${repos[@]}") local repo=$1 arch lib=$2 srepos=("${_repos[@]}")
if [[ $repo != all ]]; then if [[ $repo != all ]]; then
if ! in_array "${repo}" "${repos[@]}"; then if ! in_array "${repo}" "${_repos[@]}"; then
echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'" echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'"
echo "Try '${BASH_SOURCE[0]##*/} --help' for more information." echo "Try '${BASH_SOURCE[0]##*/} --help' for more information."
exit 1 exit 1

View File

@ -1,7 +1,8 @@
#compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco checkpkg #compdef archbuild archco arch-nspawn archrelease commitpkg finddeps makechrootpkg mkarchroot rebuildpkgs extrapkg=commitpkg corepkg=commitpkg testingpkg=commitpkg stagingpkg=commitpkg communitypkg=commitpkg community-testingpkg=commitpkg community-stagingpkg=commitpkg multilibpkg=commitpkg multilib-testingpkg=commitpkg extra-x86_64-build=archbuild testing-x86_64-build=archbuild staging-x86_64-build=archbuild multilib-build=archbuild multilib-testing-build=archbuild multilib-staging-build=archbuild kde-unstable-x86_64-build=archbuild gnome-unstable-x86_64-build=archbuild communityco=archco checkpkg sogrep
# License: Unspecified # License: Unspecified
m4_include(lib/valid-tags.sh) m4_include(lib/valid-tags.sh)
m4_include(lib/valid-repos.sh)
_archbuild_args=( _archbuild_args=(
'-c[Recreate the chroot before building]' '-c[Recreate the chroot before building]'
@ -74,6 +75,14 @@ _checkpkg_args=(
'(-h --help)'{-h,--help}'[Display usage]' '(-h --help)'{-h,--help}'[Display usage]'
) )
_sogrep_args=(
'(-v --verbose)'{-v,--verbose}'[Show matched links in addition to pkgname]'
'(-r --refresh)'{-r,--refresh}'[Refresh the links databases]'
'(-h --help)'{-h,--help}'[Display usage]'
'1:repo:(all $_repos[*])'
'2:libname'
)
_devtools_completions_all_packages() { _devtools_completions_all_packages() {
typeset -U packages typeset -U packages
packages=($(_call_program packages pacman -Sql)) packages=($(_call_program packages pacman -Sql))