Merge pull request #963 from AladW/view-options
[aurutils.git] / aur.in
blob21a64ec5e89b621e64ef214de6f3dc505c7b36e8
1 #!/bin/bash -
2 readonly argv0=aur
3 readonly aur_version='AURUTILS_VERSION'
4 readonly lib_dir=${AUR_EXEC_PATH:-'AURUTILS_LIB_DIR'}
5 shopt -s nullglob
7 if [[ -z $1 ]]; then
8 printf >&2 'usage: %s [command]\n\n' "$argv0"
9 printf >&2 'available commands:\n'
11 for p in "$lib_dir"/aur-*; do
12 printf '%q\n' "${p##*/aur-}"
13 done | column >&2
15 printf >&2 '\navailable user commands:\n'
17 compgen -c aur- | sort -u | while IFS= read -r; do
18 if ! [[ -f $lib_dir/$REPLY ]]; then
19 printf '%q\n' "${REPLY#aur-}"
21 done | column >&2
23 exit 1
26 if [[ $1 == '--version' ]]; then
27 printf >&2 'aur version %s\n' "$aur_version"
28 exit 0
31 if [[ "$PATH" != "$lib_dir:"* ]]; then
32 readonly PATH=$lib_dir:$PATH
35 if type -P "aur-$1" >/dev/null; then
36 exec "aur-$1" "${@:2}"
37 else
38 printf >&2 '%s: %q is not an aur command\n' "$argv0" "$1"
39 exit 1