summaryrefslogtreecommitdiffhomepage
path: root/pipeline/one.sh
blob: 18ffc5f3fd1194ae7dde15cb446dbb6057e8c54a (plain)
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
#!/bin/sh
# One tool, one document: the answer to "how do I run this by hand?".
#
#   sh pipeline/one.sh <tool> <file> [lang]
#
# where <tool> is one of
#
#   ssp-d ssp-g        the .ssp readers, D and Gleam
#   db-d  db-g         the .ocda.db readers
#   dump-d dump-g      the library's canonical dump of the whole model
#   agree-d agree-g    the library's two loaders against each other
#   text-d text-g      the writers. Each takes a .ssp, a .ocda.db or a
#   md-d   md-g        .sisupod and is not told which.
#   html-d html-g
#   epub-d epub-g      these two write a file, so they take --out
#   typst-d typst-g
#
# and <file> is a .ssp, a .ocda.db or a .sisupod. Output goes to stdout except
# for the epub and the typst, which name a file.
set -e
. "$(dirname "$0")/config.sh"
tool=${1:?usage: one.sh <tool> <file> [lang]}
file=${2:?usage: one.sh <tool> <file> [lang]}
lang=${3:-}

case $tool in
  ssp-d)   exec "$SSP_READER/dlang/result/bin/ssp-reader" "$file" ;;
  ssp-g)   exec "$SSP_READER/gleam/result/bin/ssp_reader" "$file" ;;
  db-d)    exec "$DB_READER/dlang/result/bin/ocda-db-reader" "$file" ;;
  db-g)    exec "$DB_READER/gleam/result/bin/ocda-db-reader" "$file" ;;
  dump-d)  exec "$OCDA_LIB/dlang/result/bin/ocda-dump" "$file" $lang ;;
  dump-g)  exec "$OCDA_LIB/gleam/result/bin/ocda-lib" dump "$file" $lang ;;
  agree-d) exec "$OCDA_LIB/dlang/result/bin/ocda-agree" "$file" $lang ;;
  agree-g) exec "$OCDA_LIB/gleam/result/bin/ocda-lib" agree "$file" $lang ;;
  *-d)     exec "$WRITERS/dlang/result/bin/ocda-write" "--${tool%-d}" "$file" $lang ;;
  *-g)     exec "$WRITERS/gleam/result/bin/ocda-write" "--${tool%-g}" "$file" $lang ;;
  *) echo "one.sh: unknown tool $tool" >&2; exit 2 ;;
esac