From 99d22e189963e836d9655862427f4c8d18ba1421 Mon Sep 17 00:00:00 2001 From: kj-sh604 Date: Tue, 10 Jun 2025 13:22:32 -0400 Subject: feat: add `gitaur` --- README | 13 ++++++++----- gitaur | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) create mode 100755 gitaur diff --git a/README b/README index 63773e4..a76e59e 100644 --- a/README +++ b/README @@ -1,14 +1,17 @@ -gitpkg +gitpkg/gitaur ------ -simple POSIX helper script that grabs the PKGBUILD of Arch Linux packages (in -the official repos) via `git`. +simple POSIX helper scripts that grabs the PKGBUILD of Arch Linux packages via +`git`. + +gitpkg = grabs PKGBUILDs from the Official Arch Repositories +gitaur = grabs PKGBUILDs from the Arch User Repository ------ usage: - gitpkg [-h|--help] - gitpkg ... + $0 [-h|--help] + $0 ... options: -h, --help diff --git a/gitaur b/gitaur new file mode 100755 index 0000000..9c8bffe --- /dev/null +++ b/gitaur @@ -0,0 +1,60 @@ +#!/bin/sh + +check_git_installed() { + if ! command -v git >/dev/null 2>&1; then + echo "error: git is not installed :( please git wget to use $0." + exit 1 + fi +} + +_base_url='https://aur.archlinux.org' + +get_url_function() { + _pkg="$1" + _url="${_base_url}/${_pkg}.git" + + echo "$_url" +} + +run_grabber_function() { + _pkg="$(echo "$1" | tr -d '[:space:]')" + _url="$(get_url_function "$_pkg")" + + git clone "$_url" +} + +grabber_function() { + for _pkg in "$@"; do + run_grabber_function "$_pkg" & + done + wait +} + +usage_function() { + cat < ... + +options: + -h, --help + print this help message +EOF +} + +check_git_installed + +while [ $# -gt 0 ]; do + case "$1" in + -*) + usage_function + exit 0 + ;; + *) + grabber_function "$@" + exit 0 + ;; + esac +done + +# vim: set filetype=sh foldmethod=marker foldlevel=0: -- cgit v1.2.3