#!/bin/bash
set -e

BINDIR=$(dirname $0)
BART_EXE=$1
shift
OUTPUT=$1
shift
XTARGETS=$@
TEST_FILE_COMMANDS=$(mktemp)

echo "AUTOGENERATED. DO NOT EDIT." > ${TEST_FILE_COMMANDS}
for cmd in ${XTARGETS} ; do
  printf "\n\n--%s--\n\n" $cmd ;
  ${BART_EXE} $cmd -h ;
done >> ${TEST_FILE_COMMANDS}
${BINDIR}/update-if-changed.sh ${TEST_FILE_COMMANDS} ${OUTPUT}
rm -rf ${TEST_FILE_COMMANDS}
