Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
set -eo pipefail
if [ -z ${DMD+x} ]
then
echo "Usage: DMD=<dmd executable> $0 <args>"
exit 1
fi
function process {
COLUMNS=$(tput cols)
declare -a MODULES
declare -A INDICATOR
ESCAPE="\033["
CLEAR="${ESCAPE}0m"
RED="${ESCAPE}0;31m"
YELLOW="${ESCAPE}1;33m"
GREEN="${ESCAPE}0;32m"
LGREEN="${ESCAPE}1;32m"
ED="$(tput ed)"
grep -v ^function | sed -e 's/\t/ /g' -e 's/ */ /g' |while read CMD ARG REST
do
INFO=${ARG%%!*}
INFO=${INFO##*.}
case "$CMD" in
parse ) MODULES+=( "$ARG" );;
semantic ) INDICATOR[$ARG]="$RED.";;
semantic2 ) INDICATOR[$ARG]="$YELLOW-";;
semantic3 ) INDICATOR[$ARG]="$GREEN-";;
code ) INDICATOR[$ARG]="$LGREEN~";;
esac
STATUS=""
PLAIN_STATUS=""
for MOD in "${MODULES[@]}"
do
STATUS+=${INDICATOR[$MOD]:- }
PLAIN_STATUS+=" "
done
if [ "$STATUS" != "" ]
then
STATUS="[${STATUS}${CLEAR}] $INFO"
PLAIN_STATUS="[${PLAIN_STATUS}] $INFO"
fi
if [[ -z "$COLUMNS" ]]
then
echo -en "$ED$STATUS\r"
else
LINES=$(echo -en "${PLAIN_STATUS}" |fold -w "$COLUMNS" |wc -l)
echo -en "$ED$STATUS\r"
if [[ "$LINES" != "0" ]]
then
tput cuu $LINES
fi
fi
done
echo -n "$ED"
}
$DMD -v $@ |process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.