-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile
executable file
·49 lines (42 loc) · 895 Bytes
/
Taskfile
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
#!/usr/bin/env bash
[ "${BASH_VERSINFO:-0}" -ge 4 ] || {
echo "bash version 4 or higher is required" >&2
exit 1
}
set -euo pipefail
function linters() {
curl -s https://golangci-lint.run/usage/linters/ |
pup ':parent-of(#enabled-by-default)' |
pup 'table td a:first-child json{}' |
jq -r '.[] | (.text + " " + .href)' |
column -t
}
declare -A config
config['dryrun']=false
_() {
if ${config['dryrun']}; then
echo "${@}"
return
fi
trap 'echo "${@}"' ERR
"${@}"
}
@debug() { echo "${@}"; }
@trace() { @debug "${@}" && "${@}"; }
@error() { echo "${@}" >&2; }
@fatal() { @error "${@}" && exit 1; }
@usage() {
cat - <<EOF
Usage: $0 <task> <args>
Tasks:
EOF
compgen -A function | grep -Ev '^(@|_)' | sort | cat -n
}
function @main() {
if [[ "${1:-}" =~ ^--dry-run|-d$ ]]; then
config['dryrun']=true
shift
fi
"${@:-@usage}"
}
@main "${@}"