File tree Expand file tree Collapse file tree 2 files changed +88
-10
lines changed Expand file tree Collapse file tree 2 files changed +88
-10
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- VERSION=$1
3
- DIR=$( cd " $( dirname " $0 " ) " ; pwd)
4
- ROOT=" ${DIR} /../"
2
+ usage () {
3
+ cat << HELP
4
+ NAME:
5
+ $0 -- watch document dir and build the book
6
+
7
+ SYNOPSIS:
8
+ $0 <version>
9
+ $0 [-h|--help]
10
+
11
+ DESCRIPTION:
12
+ A watch and build script.
13
+ This uses 'rustbook' command, and use 'RUSTBOOK' as the path if set.
14
+
15
+ -h --help Print this help.
16
+
17
+ EXAMPLE:
18
+ watch and build 1.6
19
+
20
+ $ RUSTBOOK=/path/to/rustbook $0 1.6
21
+
22
+ HELP
23
+ }
24
+
25
+
26
+ main () {
27
+ case " $1 " in
28
+ -h|--help) usage; exit 0;;
29
+ esac
30
+
31
+ if command -v inotifywait > /dev/null 2>&1 ||
32
+ command -v fswatch > /dev/null 2>&1
33
+ then
34
+ echo " You need to install 'inotifywait'(in inotify-tools) on Linux or 'fswatch' on OS X" >&2
35
+ exit 1
36
+ fi
37
+
38
+ : ${RUSTBOOK:= rustbook}
39
+ VERSION=$1
40
+ DIR=$( cd " $( dirname " $0 " ) " ; pwd)
41
+ ROOT=" ${DIR} /../"
42
+ build
43
+ watch " ${ROOT} /${VERSION} /ja"
44
+ }
45
+
5
46
6
47
build () {
7
48
make -C " ${ROOT} " RUSTBOOK=${RUSTBOOK}
@@ -27,5 +68,4 @@ watch(){
27
68
esac
28
69
}
29
70
30
-
31
- watch " ${ROOT} /${VERSION} /ja"
71
+ main " $@ "
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
- RUBY=ruby
3
- ROOT=$( cd " $( dirname " $0 " ) " ; pwd)
2
+ usage () {
3
+ cat << HELP
4
+ NAME:
5
+ $0 -- watch document dir, build the book and serve built HTML
4
6
5
- trap " trap - SIGTERM && kill -- -$$ " SIGINT SIGTERM EXIT
7
+ SYNOPSIS:
8
+ $0 <version>
9
+ $0 [-h|--help]
6
10
7
- " $RUBY " -run -e httpd -- . --port 8080 &
8
- " $ROOT /watch.sh" " $1 "
11
+ DESCRIPTION:
12
+ A watch and build and serve script.
13
+ The server will listen on localhost:8080 and document root will be 'public' dir.
14
+ This uses 'rustbook' command.
15
+ You can pass the 'rustbook' path via 'RUSTBOOK' env var.
9
16
17
+ -h --help Print this help.
18
+
19
+ EXAMPLE:
20
+ watch and build then serve HTML of 1.6
21
+
22
+ $ RUSTBOOK=/path/to/rustbook $0 1.6
23
+
24
+ BUGS:
25
+ Server program might survive even after you INTed this program.
26
+ Pathes are wellcome!
27
+
28
+
29
+ HELP
30
+ }
31
+
32
+ main () {
33
+ case " $1 " in
34
+ -h|--help) usage; exit 0;;
35
+ esac
36
+
37
+ RUBY=ruby
38
+ DIR=$( cd " $( dirname " $0 " ) " ; pwd)
39
+ ROOT=" ${DIR} /../"
40
+
41
+ trap " trap - SIGTERM && kill -- -$$ " SIGINT SIGTERM EXIT
42
+
43
+ " $RUBY " -run -e httpd -- " ${ROOT} /public" --port 8080 &
44
+ " $DIR /watch.sh" " $@ "
45
+ }
46
+
47
+ main " $@ "
You can’t perform that action at this time.
0 commit comments