#!/usr/bin/env bash

export RAILS_ENV=production
export SECRET_KEY_BASE=42
export SEMANTIC_LOGGER_APP=egr

function usage {
  echo "argument required:"
  echo "  server"
  echo "  console"
  echo "  <...> (any rake entry)"
}

command=$1
[[ -z "$command" ]] && usage && exit
if [[ $command =~ 'server|s' ]]; then
  [[ -d public/assets ]] && echo "ASSETS are already precompiled: MODIFIED_TIME" || rails assets:precompile
  rails server
else
  rails $command
fi