diff options
author | Yash Karandikar | 2020-03-15 19:34:00 -0500 |
---|---|---|
committer | Yash Karandikar | 2020-03-15 19:34:00 -0500 |
commit | 333c78e787d1a4701243a906250d53ee1a04793f (patch) | |
tree | 58b5c22e0807180c330bfaf6262154371d47ce09 | |
parent | dec6f1374cce2b92c608a45d63c5b63447b6e2aa (diff) | |
parent | 238efbf12f58ccd8b2e6ad5d1d6e21e9ed5a3a7c (diff) | |
download | aur-333c78e787d1a4701243a906250d53ee1a04793f.tar.gz |
Create search functionality and improve tests
-rw-r--r-- | .travis.yml | 16 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rwxr-xr-x | haur | 29 |
3 files changed, 41 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml index 2659942fe620..8b5e0add9b32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,16 @@ language: bash - script: - - make test + - "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash" +services: + - docker +archlinux: + packages: + - bash + - git + - namcap + mount: + - ~/.pkg-cache:/var/cache/pacman/pkg + script: + - "bash test.sh" + - "namcap PKGBUILD" + - "makepkg -Ccsi --noconfirm" @@ -8,7 +8,7 @@ arch=('any') url="https://github.com/karx1/haur" license=('LGPLv3') provides=("haur") -depends=('bash' 'git') +depends=('bash' 'git' 'jq') source=("haur" "haurrc" "Makefile") prepare () { make clean @@ -16,6 +16,6 @@ prepare () { package () { make install srcdir=$srcdir pkgdir=$pkgdir } -md5sums=('84bb94f82233eeeebb2264c2fa023fe9' +md5sums=('8dc686d326d48ba863b92db6f1d86a39' '2c9bb36e3d797a6a3462bf69b6033cfe' 'c1051c8c4fe078e1f90b1ff0278f6a8d') @@ -24,13 +24,13 @@ if [ ! "$HAUR_NO_COLORS" == "y" ]; then ncolors=$(tput colors 2>/dev/null) if test -n "$ncolors" && test "$ncolors" -ge 8; then - # bold="$(tput bold 2>/dev/null)" + bold="$(tput bold 2>/dev/null)" # underline="$(tput smul 2>/dev/null)" # standout="$(tput smso 2>/dev/null)" normal="$(tput sgr0 2>/dev/null)" # black="$(tput setaf 0 2>/dev/null)" red="$(tput setaf 1 2>/dev/null)" - # green="$(tput setaf 2 2>/dev/null)" + green="$(tput setaf 2 2>/dev/null)" # yellow="$(tput setaf 3 2>/dev/null)" blue="$(tput setaf 4 2>/dev/null)" # magenta="$(tput setaf 5 2>/dev/null)" @@ -40,6 +40,16 @@ if [ ! "$HAUR_NO_COLORS" == "y" ]; then fi fi +search () { + search_term=$1 + mapfile -t name < <(curl -s "https://aur.archlinux.org/rpc/?v=5&type=search&arg=$search_term" | jq -r ".results" | jq -r ".[] | .Name") + mapfile -t version < <(curl -s "https://aur.archlinux.org/rpc/?v=5&type=search&arg=$search_term" | jq -r ".results" | jq -r ".[] | .Version") + mapfile -t description < <(curl -s "https://aur.archlinux.org/rpc/?v=5&type=search&arg=$search_term" | jq -r ".results" | jq -r ".[] | .Description") + for (( i=0; i<${#name[@]}; i++ )); do + echo "${bold}${blue}${name[i]} ${green}${version[i]}${normal}: ${description[i]}" + done +} + REMOVE=false CLEAR_CACHE=false UPDATE=false @@ -47,6 +57,7 @@ UPDATE=false for arg in "$@"; do shift case "$arg" in + "--search") set -- "$@" "-s" ;; "--update") set -- "$@" "-u" ;; "--remove") set -- "$@" "-r" ;; "--clear-cache") set -- "$@" "-c" ;; @@ -57,8 +68,11 @@ for arg in "$@"; do done shift $((OPTIND -1)) -while getopts ":urch" opt; do +while getopts ":surch" opt; do case $opt in + s ) + SEARCH=true + ;; u ) UPDATE=true ;; @@ -69,7 +83,7 @@ while getopts ":urch" opt; do CLEAR_CACHE=true ;; h ) - echo "Usage: haur [--remove | -r] | [--clear-cache | -c] [--update | -u] <package names>" + echo "Usage: haur [--remove | -r] | [--clear-cache | -c] [--update | -u] [--search | -s]<package names>" exit 0 ;; \?) @@ -83,6 +97,13 @@ if [ "$HAUR_ALWAYS_CLEAR_CACHE" == "y" ]; then CLEAR_CACHE=true fi +if [ $SEARCH == true ]; then + for PACKAGE_NAME in "$@"; do + search "${PACKAGE_NAME}" || die "Something went wrong while searching for that package." + done + exit 0 +fi + if [ $REMOVE == true ]; then for PACKAGE_NAME in "$@"; do echo "${blue}Removing $PACKAGE_NAME...${normal}" |