summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2019-09-13 01:32:57 +0200
committerLevente Polyak <anthraxx@archlinux.org>2019-09-28 00:16:09 +0200
commit64b7d995040fc670aaed5fbd048157b3feba0574 (patch)
treecfb9955b87bea4a329c3372da874d149102c813d
parentf32a264796b3b43662b4734f1730d7a819d32484 (diff)
downloaddevtools-64b7d995040fc670aaed5fbd048157b3feba0574.tar.xz
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>
-rw-r--r--.gitignore1
-rw-r--r--Makefile4
-rw-r--r--lib/valid-repos.sh31
-rwxr-xr-xsogrep.in (renamed from sogrep)12
-rw-r--r--zsh_completion.in11
5 files changed, 49 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index b63587b..6a1d1e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,5 @@ zsh_completion
find-libdeps
crossrepomove
arch-nspawn
+sogrep
doc/*.1
diff --git a/Makefile b/Makefile
index 8d54ed4..82bc4c1 100644
--- a/Makefile
+++ b/Makefile
@@ -16,12 +16,12 @@ IN_PROGS = \
crossrepomove\
arch-nspawn \
mkarchroot \
- makechrootpkg
+ makechrootpkg \
+ sogrep
BINPROGS = \
$(IN_PROGS) \
offload-build \
- sogrep
CONFIGFILES = \
makepkg-x86_64.conf \
diff --git a/lib/valid-repos.sh b/lib/valid-repos.sh
new file mode 100644
index 0000000..252fdcf
--- /dev/null
+++ b/lib/valid-repos.sh
@@ -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
+)
diff --git a/sogrep b/sogrep.in
index 56a0e70..055c61f 100755
--- a/sogrep
+++ b/sogrep.in
@@ -21,10 +21,8 @@
# globals
: ${SOLINKS_MIRROR:="https://mirror.pkgbuild.com"}
: ${SOCACHE_DIR:="${XDG_CACHE_HOME:-${HOME}/.cache}/sogrep"}
-repos=('staging' 'testing' 'core' 'extra'
- 'community-staging' 'community-testing' 'community'
- 'multilib-staging' 'multilib-testing' 'multilib'
- 'gnome-unstable' 'kde-unstable')
+
+m4_include(lib/valid-repos.sh)
arches=('x86_64')
# options
@@ -39,7 +37,7 @@ recache() {
(( VERBOSE )) && verbosity=--progress-bar
- for repo in "${repos[@]}"; do
+ for repo in "${_repos[@]}"; do
for arch in "${arches[@]}"; do
rm -rf "${SOCACHE_DIR}/${arch}/${repo}"
mkdir -p "${SOCACHE_DIR}/${arch}/${repo}"
@@ -49,10 +47,10 @@ recache() {
}
search() {
- local repo=$1 arch lib=$2 srepos=("${repos[@]}")
+ local repo=$1 arch lib=$2 srepos=("${_repos[@]}")
if [[ $repo != all ]]; then
- if ! in_array "${repo}" "${repos[@]}"; then
+ if ! in_array "${repo}" "${_repos[@]}"; then
echo "${BASH_SOURCE[0]##*/}: unrecognized repo '$repo'"
echo "Try '${BASH_SOURCE[0]##*/} --help' for more information."
exit 1
diff --git a/zsh_completion.in b/zsh_completion.in
index 78330ea..72dbfa3 100644
--- a/zsh_completion.in
+++ b/zsh_completion.in
@@ -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
m4_include(lib/valid-tags.sh)
+m4_include(lib/valid-repos.sh)
_archbuild_args=(
'-c[Recreate the chroot before building]'
@@ -74,6 +75,14 @@ _checkpkg_args=(
'(-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() {
typeset -U packages
packages=($(_call_program packages pacman -Sql))