#!/usr/bin/env bash

set -euo pipefail

if [ $# == 0 ] || [ "$1" == '--help' ] || [ "$1" == '-h' ]; then
  cat <<USAGE
Usage: $0 your-program [your-program-options]

Runs the given command line with debug info (useful for debugging tests).
USAGE

  exit 1
fi

echo Date: $(date)
echo Command line: $@
echo Hostname: $(hostname)
echo Runfiles count: $(find -type f | wc --lines)
echo Rundirs count: $(find -type d | wc --lines)
echo Runfiles size: $(du -hs . | awk '{print $1}')
echo ====================================== env =====================================
env
echo ================================================================================

time "$@"
