-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmake-cli.sh
executable file
·65 lines (53 loc) · 1.3 KB
/
make-cli.sh
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
#!/usr/bin/env bash
set -eu -o pipefail
[ -z ${DEBUG-} ] || set -x
m() {
## Usage# m "$MESSAGE"
printf "[- INFO --- ] $1\n"
}
err() {
## Usage (w exit) # mkdir "$DIR" || err 'cannot create dir' 1
## Usage (wo exit) # mkdir "$DIR" || err 'cannot create dir'
local message="$1"; shift
local exit_code="$1"; shift
[ -n "$message" ] && printf "[- ERR ---- ] $message\n" >&2
[ -n "$exit_code" ] && exit "$exit_code"
}
ergogen_build() {
local target="${1-run}"
docker build \
--no-cache \
--target "${target}" \
-t ergogen-cli:latest \
-f Dockerfile.cli \
.
}
ergogen_run() {
local args="${1:-}"
local cmd="
docker run \
-it \
--rm \
--init \
--name ergogen-cli \
-v $(pwd)/footprints:/usr/local/lib/node_modules/ergogen/src/footprints \
-v $(pwd)/input:/work/input \
-v $(pwd)/output:/work/output \
ergogen-cli:latest
"
[ ! -z "$args" ] && cmd="$cmd $args"
$cmd
}
main() {
[ $# -eq 0 ] && err "available subcommands: build, run" 2
local cmd="$1"; shift
case $cmd in
"build" | "run")
$"ergogen_$cmd" "$@"
;;
*)
err "command $cmd is not supported" 3
;;
esac
}
main "$@"