##
##  monotone-colorize -- colorize output of mtn(1)
##  Copyright (c) 2007 Ralf S. Engelschall <rse@engelschall.com>
##
##  This program is free software; you can redistribute it and/or modify
##  it under the terms of the GNU General Public License as published by
##  the Free Software Foundation; either version 2 of the License, or
##  (at your option) any later version.
##
##  This program is distributed in the hope that it will be useful,
##  but WITHOUT ANY WARRANTY; without even the implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
##  General Public License for more details.
##
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to the Free Software
##  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
##  USA, or contact Ralf S. Engelschall <rse@engelschall.com>.
##
##  monotone-colorize.bashrc: shell integration (language: GNU Bash)
##

#   wrap mtn(1) command for colorization via monotone-colorize(1)
mtn () {
    case "$1" in
        u|up|upd|upda|updat|update )
            shift
            @l_prefix@/bin/mtn update ${1+"$@"} 2>&1 |\
            @l_prefix@/bin/monotone-colorize update
            ;;
        s|st|sta|stat|statu|status )
            shift
            @l_prefix@/bin/mtn status ${1+"$@"} |\
            @l_prefix@/bin/monotone-colorize status
            ;;
        l|lo|log )
            shift
            @l_prefix@/bin/mtn log ${1+"$@"} |\
            @l_prefix@/bin/monotone-colorize log
            ;;
        d|di|dif|diff )
            shift
            @l_prefix@/bin/mtn --quiet diff --no-show-header ${1+"$@"} |\
            @l_prefix@/bin/monotone-colorize diff
            ;;
        ls|l|li|lis|list )
            case "$2" in
                t|ta|tag|tags )
                    shift; shift
                    @l_prefix@/bin/mtn list tags ${1+"$@"} |\
                    @l_prefix@/bin/monotone-colorize list-tags
                    ;;
                b|br|bra|bran|branc|branch|branche|branches )
                    shift; shift
                    @l_prefix@/bin/mtn list branches ${1+"$@"} |\
                    @l_prefix@/bin/monotone-colorize list-branches
                    ;;
                * )
                    @l_prefix@/bin/mtn ${1+"$@"}
                    ;;
            esac
            ;;
        * )
            @l_prefix@/bin/mtn ${1+"$@"}
            ;;
    esac
}

