COMP: lagrangian: moved include files to .C
[OpenFOAM-2.0.x.git] / bin / tools / org-batch
blobc5d8ac60c20417aecbbee445f28df4e3eb8f082e
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # org-batch
28 # Description
29 # Batch process emacs org-mode files to create html/LaTeX etc.
31 #------------------------------------------------------------------------------
32 Script=${0##*/}
34 usage() {
35 exec 1>&2
36 while [ "$#" -ge 1 ]; do echo "$1"; shift; done
37 cat<<USAGE
39 Usage: $Script [OPTIONS] file1 [.. fileN]
40 options:
41 -html create html (default)
42 -latex create LaTeX
43 -pdflatex create pdf via pdflatex
45 * Batch process emacs org-mode files to create html/LaTeX etc.
47 USAGE
48 exit 1
52 # default is html export:
53 mode=html
54 unset makePDF
56 echo "have $Script"
57 case $Script in
58 *pdflatex)
59 mode=latex
60 makePDF=pdflatex
62 *latex)
63 mode=latex
65 *html)
66 mode=html
68 esac
70 # parse options
71 while [ "$#" -gt 0 ]
73 case "$1" in
74 -h | -help)
75 usage
77 -html)
78 mode=html
79 shift
81 -latex)
82 mode=latex
83 shift
85 -pdflatex)
86 mode=latex
87 makePDF=pdflatex
88 shift
90 -*)
91 usage "unknown option: '$*'"
94 break
96 esac
97 done
99 # default is the current directory
100 [ "$#" -gt 0 ] || usage "No files specified"
102 type emacs >/dev/null 2>&1 || usage "No emacs found in PATH"
105 for org
107 echo "Processing: $org"
108 echo "----------"
109 if [ -f "$org" ]
110 then
111 emacs --batch -l org --visit=$org \
112 --funcall org-export-as-$mode-batch
114 # post-processing step to create pdf
115 case "$makePDF" in
116 pdflatex)
117 input="${org%.org}.tex"
119 if [ -f "$input" ]
120 then
121 pdflatex "$input"
122 else
123 echo "No $input to convert to pdf"
126 esac
128 else
129 echo "File not found"
131 echo "----------"
132 done
134 #------------------------------------------------------------------------------