10555
|
1 |
#!/usr/bin/env bash
|
3640
|
2 |
#
|
9788
|
3 |
# Author: Markus Wenzel, TU Muenchen
|
3640
|
4 |
#
|
7766
|
5 |
# DESCRIPTION: Isabelle graph browser
|
3640
|
6 |
|
|
7 |
|
10511
|
8 |
PRG="$(basename "$0")"
|
3640
|
9 |
|
|
10 |
function usage()
|
|
11 |
{
|
|
12 |
echo
|
28650
|
13 |
echo "Usage: isabelle $PRG [OPTIONS] [GRAPHFILE]"
|
3640
|
14 |
echo
|
7766
|
15 |
echo " Options are:"
|
20569
|
16 |
echo " -c cleanup -- remove GRAPHFILE after use"
|
11801
|
17 |
echo " -o FILE output to FILE (ps, eps, pdf)"
|
7766
|
18 |
echo
|
3640
|
19 |
exit 1
|
|
20 |
}
|
|
21 |
|
11801
|
22 |
function fail()
|
|
23 |
{
|
|
24 |
echo "$1" >&2
|
|
25 |
exit 2
|
|
26 |
}
|
|
27 |
|
|
28 |
|
7766
|
29 |
## process command line
|
|
30 |
|
|
31 |
# options
|
|
32 |
|
20569
|
33 |
CLEAN=""
|
11801
|
34 |
OUTFILE=""
|
7766
|
35 |
|
20569
|
36 |
while getopts "co:" OPT
|
7766
|
37 |
do
|
|
38 |
case "$OPT" in
|
20569
|
39 |
c)
|
|
40 |
CLEAN=true
|
7766
|
41 |
;;
|
11801
|
42 |
o)
|
|
43 |
OUTFILE="$OPTARG"
|
|
44 |
;;
|
7766
|
45 |
\?)
|
|
46 |
usage
|
|
47 |
;;
|
|
48 |
esac
|
|
49 |
done
|
|
50 |
|
|
51 |
shift $(($OPTIND - 1))
|
|
52 |
|
|
53 |
|
|
54 |
# args
|
|
55 |
|
|
56 |
GRAPHFILE=""
|
9788
|
57 |
[ "$#" -gt 0 ] && { GRAPHFILE="$1"; shift; }
|
|
58 |
[ "$#" -ne 0 ] && usage
|
7766
|
59 |
|
3640
|
60 |
|
|
61 |
## main
|
|
62 |
|
27907
|
63 |
classpath "$ISABELLE_HOME/lib/browser/GraphBrowser.jar"
|
25650
|
64 |
|
9794
|
65 |
if [ -z "$GRAPHFILE" ]; then
|
26230
|
66 |
[ -d "$ISABELLE_BROWSER_INFO" ] && cd "$ISABELLE_BROWSER_INFO"
|
28500
|
67 |
exec "$ISABELLE_TOOL" java GraphBrowser.GraphBrowser
|
9794
|
68 |
else
|
20569
|
69 |
PRIVATE_FILE="${ISABELLE_TMP:-/tmp}/$$"$(basename "$GRAPHFILE")
|
|
70 |
if [ -n "$CLEAN" ]; then
|
|
71 |
mv -f "$GRAPHFILE" "$PRIVATE_FILE" || fail "Cannot move file: $FILE"
|
|
72 |
else
|
|
73 |
cp -f "$GRAPHFILE" "$PRIVATE_FILE" || fail "Cannot copy file: $FILE"
|
|
74 |
fi
|
|
75 |
|
11843
|
76 |
PDF=""
|
11801
|
77 |
case "$OUTFILE" in
|
|
78 |
*.pdf)
|
11843
|
79 |
OUTFILE="${OUTFILE%%.pdf}.eps"
|
11801
|
80 |
PDF=true
|
|
81 |
;;
|
|
82 |
esac
|
|
83 |
|
11843
|
84 |
if [ -z "$OUTFILE" ]; then
|
28500
|
85 |
"$ISABELLE_TOOL" java GraphBrowser.GraphBrowser "$(jvmpath "$PRIVATE_FILE")"
|
11813
|
86 |
else
|
28500
|
87 |
"$ISABELLE_TOOL" java GraphBrowser.Console "$(jvmpath "$PRIVATE_FILE")" "$(jvmpath "$OUTFILE")"
|
11813
|
88 |
fi
|
11843
|
89 |
RC="$?"
|
11801
|
90 |
|
|
91 |
if [ -n "$PDF" ]; then
|
11843
|
92 |
"$ISABELLE_EPSTOPDF" "$OUTFILE" || fail "Failed to produce pdf output"
|
11801
|
93 |
fi
|
|
94 |
|
20569
|
95 |
rm -f "$PRIVATE_FILE"
|
9794
|
96 |
fi
|
11843
|
97 |
|
|
98 |
exit "$RC"
|