aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.local/bin/wgetpkg60
1 files changed, 60 insertions, 0 deletions
diff --git a/.local/bin/wgetpkg b/.local/bin/wgetpkg
new file mode 100755
index 0000000..d1738c8
--- /dev/null
+++ b/.local/bin/wgetpkg
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+check_wget_installed() {
+ if ! command -v wget >/dev/null 2>&1; then
+ echo "error: wget is not installed :( please install wget to use wgetpkg."
+ exit 1
+ fi
+}
+
+_base_url='https://aur.archlinux.org/cgit/aur.git/snapshot'
+
+get_url_function() {
+ _pkg="$1"
+ _url="${_base_url}/${_pkg}.tar.gz"
+
+ echo "$_url"
+}
+
+run_wgetpkg_function() {
+ _pkg="$(echo "$1" | tr -d '[:space:]')"
+ _url="$(get_url_function "$_pkg")"
+
+ wget --no-verbose "$_url"
+}
+
+wgetpkg_function() {
+ for _pkg in "$@"; do
+ run_wgetpkg_function "$_pkg" &
+ done
+ wait
+}
+
+usage_function() {
+ cat <<EOF
+Usage:
+ wgetpkg [-h|--help]
+ wgetpkg <pkg> <pkg>...
+
+Options:
+ -h, --help
+ print this help message
+EOF
+}
+
+check_wget_installed
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -*)
+ usage_function
+ exit 0
+ ;;
+ *)
+ wgetpkg_function "$@"
+ exit 0
+ ;;
+ esac
+done
+
+# vim: set filetype=sh foldmethod=marker foldlevel=0: