summaryrefslogtreecommitdiff
path: root/gitaur
blob: 9c8bffe6ed7cf0dac2ea1f03b4ddb3af305a5695 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 <<EOF
usage:
    $0 [-h|--help]
    $0 <pkg> <pkg>...

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: