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