-
Notifications
You must be signed in to change notification settings - Fork 9
/
aapb
executable file
·56 lines (42 loc) · 1.14 KB
/
aapb
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
#!/bin/bash
HELP="AAPB init script\n\n
A basic CLI for managing AAPB \n\n
USAGE:\n\n
\t ./aapb COMMAND [args] \n\n
COMMANDS:\n\n
\t b | build \t build the docker image\n
\t c | cmd \t run a bash command with the docker image\n
\t d | dev \t start a development server\n
\t f | format \t run the rubocop formatter\n
\t h | help \t prints this help text\n
\t t | test \t run the test suite\n
"
DOCKER_RUN="docker run -it --rm --name aapb"
DOCKER_EXEC="docker exec -it"
VOLUME_MOUNT="-v $(pwd):/usr/src/app/"
PORT_MOUNT="-p 3000:3000 -p 8983:8983"
if [ -z $1 ]; then
echo -e $HELP
elif [ $1 = "build" -o $1 = "b" ]; then
shift
docker build -t aapb . "$@"
elif [ $1 = "cmd" -o $1 = "c" ]; then
shift
CMD="$DOCKER_EXEC aapb"
if [ -z $1 ]; then
$CMD bash
else $CMD "$@"
fi
elif [ $1 = "dev" -o $1 = "d" ]; then
shift
$DOCKER_RUN $PORT_MOUNT $VOLUME_MOUNT aapb "$@"
elif [ $1 = "test" -o $1 = "t" ]; then
shift
$DOCKER_EXEC aapb bundle exec rspec "$@"
elif [ $1 = "format" -o $1 = "f" ]; then
shift
$DOCKER_EXEC aapb rubocop --auto-correct "$@"
else
echo "Unrecognezed command: $@"
echo -e $HELP
fi