#! /bin/sh

set -e

# Collect help messages from all tools, and verify that it is written
# to stdout (not stderr), and that exit code is success.

exec > test.help

die() {
    echo "$@" >&2
    exit 1
}

test_one() {
    echo "=== $* ==="
    if "$@" 2> test.stderr ; then true; else die "Exit code $? from: $*"; fi
    if [ -s test.stderr ] ; then die "Stderr output from: $*" ; fi
}

test_one ./bin/sigsum-key --help
test_one ./bin/sigsum-key generate --help
test_one ./bin/sigsum-key sign --help
test_one ./bin/sigsum-key verify --help
test_one ./bin/sigsum-key to-hash --help
test_one ./bin/sigsum-key to-hex --help
test_one ./bin/sigsum-key from-hex --help
test_one ./bin/sigsum-key to-vkey --help
test_one ./bin/sigsum-key from-vkey --help
test_one ./bin/sigsum-token --help
test_one ./bin/sigsum-token create --help
test_one ./bin/sigsum-token record --help
test_one ./bin/sigsum-token verify --help
test_one ./bin/sigsum-submit --help
test_one ./bin/sigsum-verify --help
test_one ./bin/sigsum-witness --help
test_one ./bin/sigsum-monitor --help
