Files
spider-compiler/run.sh
T

36 lines
1.3 KiB
Bash

#!/usr/bin/env bash
BOLD="\033[1m"
RESET="\033[0m"
SUCCESS="\033[38;2;80;220;100m"
FAIL="\033[38;2;255;90;90m"
INFO="\033[38;2;100;200;255m"
DIM="\033[2m"
LOG="./out/out.log"
# Start
printf "${DIM}────────────────────────────────────────${RESET}\n"
printf "${INFO}${BOLD}> Running...${RESET}\n"
printf "${DIM}────────────────────────────────────────${RESET}\n\n"
# Send both stdout and stderr to the console and the log file.
start=$(date +%s.%N)
./out/out "$@" 2>&1 | tee "$LOG"
status=${PIPESTATUS[0]}
end=$(date +%s.%N)
elapsed=$(awk "BEGIN { printf \"%.3f\", $end - $start }")
# Status!
printf "\n${DIM}────────────────────────────────────────${RESET}\n"
if (( status == 0 )); then
printf "${SUCCESS}${BOLD}✓ Success${RESET} (exit %d)\n" "$status"
else
printf "${FAIL}${BOLD}✗ Failed${RESET} (exit %d)\n" "$status"
fi
printf "${INFO}${BOLD}> Time${RESET} ${elapsed}s\n"
printf "${INFO}${BOLD}> Log${RESET} %s\n" "$LOG"
printf "${DIM}────────────────────────────────────────${RESET}"
exit "$status"