-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·32 lines (29 loc) · 842 Bytes
/
run
File metadata and controls
executable file
·32 lines (29 loc) · 842 Bytes
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
#! /usr/bin/env bash
set -euo pipefail
shopt -s globstar
trap 'echo fatal: $0:$LINENO >&2' ERR
cmd="${1:-help}"
case "$cmd" in
# -- run shfmt on all bash scripts
format)
find bin dotfiles -type f -print0 \
| xargs -0 grep -lZE '^#! ?/usr/bin/env bash|^#!/usr/bin/env bash|^#! ?/bin/bash' \
| xargs -0 shfmt -i 2 -ln bash -w
;;
# -- run shellcheck on all bash scripts
lint)
find bin dotfiles -type f -print0 \
| xargs -0 grep -lZE '^#! ?/usr/bin/env bash|^#!/usr/bin/env bash|^#! ?/bin/bash' \
| xargs -0 shellcheck -x
;;
# -- install required dev tools
setup)
bin/setup
;;
help | *)
echo "Usage: ./run <command>"
echo ""
echo "Commands:"
awk '/^# -- /{desc=substr($0, index($0,"-- ")+3)} /\)$/ && desc{cmd=$0; gsub(/[[:space:]()|*]/, "", cmd); printf " %-20s %s\n", cmd, desc; desc=""}' "$0"
;;
esac