#!/usr/bin/env bash text=${1:-coverage} textwidth=$(($(echo -n "$text"|wc -m) * 7 + 6)) numwidth=54 totalwidth=$(($textwidth + $numwidth)) coverage=$(grep -m 1 'headerCovTableEntry[a-zA-Z].*[0-9]*' Libidn2-*-coverage/index.html|sed 's/^.*>\([0-9]\+\.[0-9]\+\).*/\1/'); coverage=$(printf %.2f $coverage) inum=$(echo $coverage|cut -d'.' -f1) if [ -z "$inum" ]; then inum="0"; fi coverage="$coverage%" # https://www.w3.org/TR/SVG11/types.html#ColorKeywords if [ $inum -ge 90 ]; then # color="lawngreen" color="#4c1" elif [ $inum -ge 80 ]; then color="yellow" elif [ $inum -ge 70 ]; then color="orange" else color="red" fi cat <badge.svg ${text} ${text} ${coverage} ${coverage} EOF