summaryrefslogtreecommitdiffstats
path: root/ctl.sh
blob: 816899af9002d0ea47181a180a996808532de814 (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
#!/usr/bin/env bash
set -e

function_to_run=$1

export PROJECT_ROOT
export GORELEASER_VERSION=1.10.2

PROJECT_ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

function _includes_path {
	echo "$PROJECT_ROOT"/scripts
}

function _load_includes {
	for file in "$(_includes_path)"/*.bash; do
		# shellcheck disable=1090
		source "$file"
	done
}

_load_includes

if [[ $(type -t "$function_to_run") != function ]]; then
	echo "Subcommand: '$function_to_run' not found."
	exit 1
fi

shift

pushd "$PROJECT_ROOT" || _panic
"$function_to_run" "$@"
popd || _panic