#!/bin/bash
set -e

echo "Testing management commands start!"
failed=0
for i in `ls */management/commands/ | grep .py$ | grep -v __init__ | sed 's/[.]py$//'`; do
    if ! $(./manage.py $i --help >/dev/null); then
        failed=$(expr $failed + 1)
        echo "ERROR: \`./manage.py $i --help\` crashes!";
    fi
done

if [ $failed -gt 0 ]; then
   echo
   echo "$failed management commands don't start!"
   exit 1
fi
echo "All management commands start!"
