#!/bin/sh
set -eu

output=$(mktemp)
trap 'rm -f "$output"' EXIT

for option in -h --help; do
    xvfb-run -a stimfit "$option" >"$output" 2>&1
    grep -q '^Usage:' "$output"
done

if xvfb-run -a stimfit --stimfit-invalid-option >"$output" 2>&1; then
    cat "$output"
    echo "stimfit unexpectedly accepted an invalid option" >&2
    exit 1
fi
grep -qi 'unknown.*option' "$output"
