# encoding: ascii
# api: powershell
# title: Colorize Subversion SVN
# description: Colorize Subversion SVN STAT, UPDATE and DIFF (without params) output.
# version: 0.1
# type: function
# author: Bishop
# license: CC0
# x-poshcode-id: 1143
# x-derived-from-id: 1148
# x-archived: 2009-06-07T13:29:14
#
# Here’s a PowerShell functions that you can use to make those numerous SVN commands you run every day via the PowerShell CLI a little easier to read by adding colors.
#
# draw output
function drawlines($colors, $lines) {
	if (!$lines) { return }
	foreach ($line in $lines) {
		$color = $colors[[string]$line[0]]
		if ($color) {
			write-host $line -Fore $color
		} else {
			write-host $line
		}
	}
}

# svn stat
function ss {
	drawlines @{ "A"="Magenta"; "D"="Red"; "C"="Yellow"; "G"="Blue"; "M"="Cyan"; "U"="Green"; "?"="DarkGray"; "!"="DarkRed" } (svn stat)
}

# svn update
function su {
	drawlines @{ "A"="Magenta"; "D"="Red"; "U"="Green"; "C"="Yellow"; "G"="Blue"; } (svn up)
}

# svn diff
function sd {
	drawlines @{ "@"="Magenta"; "-"="Red"; "+"="Green"; "="="DarkGray"; } (svn diff)
}
