#!/bin/sh

BASE_DIR="${0%%/*}"

source ${BASE_DIR}/lib/bash.sh

if [ "$#" != 2 ]
then
	die "${PROG_NAME} SOURCE_DIRECTORY TARGET_DIRECTORY"
else
	SOURCE="${1}"
	TARGET="${2}"
	[ -d "${SOURCE}" ] || die "SOURCE_DIRECTORY must be a directory (containing a folder for EDdA and one for LGE with the structure found in Source.squashfs)"
	[ -d "${TARGET}" ] || die "TARGET_DIRECTORY must be a directory (where output will be generated)"
fi

FILES_TSV="${TARGET}/files.tsv"
printf "book	tome	rank	headWord	name	page\n" > "${FILES_TSV}"
${BASE_DIR}/scripts/EDdA/extract-from-source.sh "${SOURCE}/EDdA/ARTFL" ${TARGET} >> "${FILES_TSV}"
${BASE_DIR}/scripts/LGE/extract-from-source.sh "${SOURCE}/LGE/BnF" ${TARGET} >> "${FILES_TSV}"
