diff --git a/sunrise-commit b/sunrise-commit index 0ed33d9..679abad 100755 --- a/sunrise-commit +++ b/sunrise-commit @@ -9,12 +9,12 @@ say() { } die() { - say "${@}" + say "${RED}${@}${RESET}" exit 1 } sayv() { - [ -n "${SC_VERBOSE}" ] && say "${@}" + [ -n "${SC_VERBOSE}" ] && say "${GREEN}${@}${RESET}" } req() { @@ -112,13 +112,14 @@ Options: -V, --version print version string, -c, --changelog backwards compat (ignored), + -C, --nocolor disable colorful output, -v, --verbose enable verbose output. _EOH_ } # Guess what! main() { - local commitmsg + local commitmsg monochrome unset SC_VERBOSE while [ ${#} -gt 0 ]; do @@ -135,6 +136,9 @@ main() { -c|--changelog) # Now changelog entries are implicit -- backwards compat. ;; + -C|--nocolor) + monochrome=1 + ;; -v|--verbose) SC_VERBOSE=1 ;; @@ -151,6 +155,25 @@ main() { shift done + if [ -n "${monochrome}" ]; then + RESET= + RED= + GREEN= + BGREEN= + YELLOW= + WHITE= + else + local esc + esc=$(printf '\033[') + + RESET=${esc}0m + RED="${esc}1;31m" + GREEN=${esc}32m + BGREEN="${esc}1;32m" + YELLOW="${esc}1;33m" + WHITE="${esc}1;37m" + fi + [ -n "${commitmsg}" ] || die 'No commit message provided.' find_repo @@ -178,11 +201,12 @@ main() { if [ -n "${bns}" ]; then echo - local bn + local bn cbn for bn in ${bns}; do + cbn=#${WHITE}${bn}${NORMAL} wget -q http://bugs.gentoo.org/show_bug.cgi?id=${bn} -O - \ - | sed -e 's; *