#!/bin/bash

if [ "$1" == "help" ]; then
	echo "Syntax: gridlabd validate [options] ..."
	exit 0
fi

if [ ! -d "build-aux" ]; then
	echo "ERROR: validate must be run from top source directory (where build-aux is found)" > /dev/stderr
	exit 1
fi

if [ ! "$(gridlabd version)" == "$(build-aux/version.sh --name)" ]; then
	echo "ERROR: installed gridlabd version '$(gridlabd version)' does not match current top source version '$(build-aux/version.sh --name)'" > /dev/stderr
	exit 1
fi

echo "Running CLI version validation..."
gridlabd $* --validate

echo "Running Python version validation..."
gridlabd python gldcore/link/python/validate.py $*

