-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathrun
More file actions
executable file
·71 lines (62 loc) · 1.75 KB
/
Copy pathrun
File metadata and controls
executable file
·71 lines (62 loc) · 1.75 KB
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
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
################################################################################
# Task runner for the Tabular Editor docs repo
#
# Dispatches to the command scripts in build_scripts/run_scripts/. Always runs
# from the repo root, regardless of the caller's working directory, so file
# arguments are repo-root-relative.
#
# Usage:
# ./run # this documentation plus the command list (alias: help)
# ./run <cmd> [args] # run a command
# ./run <cmd> help # detailed help for one command
# ./run commands # just the command list (alias: --list)
#
# On Windows, invoke from Git Bash (`./run <cmd>`, or `bash run <cmd>`).
################################################################################
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCRIPTS="$ROOT/build_scripts/run_scripts"
# shellcheck source=build_scripts/run_scripts/lib.sh
source "$SCRIPTS/lib.sh"
cd "$ROOT"
commands() {
# List every command script with the first line of its banner.
printf 'Commands:\n'
local script name
for script in "$SCRIPTS"/*.sh; do
name="$(basename "$script" .sh)"
if [ "$name" = "lib" ]; then
continue
fi
printf ' %-12s %s\n' "$name" "$(banner_title "$script")"
done
printf '\nRun ./run <command> help for details on one command.\n'
printf 'Run ./run help for full runner documentation.\n'
}
help() {
# Full runner documentation (the banner above) plus the command index.
banner_help "$0"
commands
}
cmd="${1:-help}"
if [ "$#" -gt 0 ]; then
shift
fi
case "$cmd" in
commands | --list)
commands
exit 0
;;
help | --help | -h)
help
exit 0
;;
esac
script="$SCRIPTS/$cmd.sh"
if [ ! -f "$script" ]; then
error "unknown command: $cmd"
commands >&2
exit 2
fi
exec bash "$script" "$@"