-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.ps1
More file actions
22 lines (21 loc) · 711 Bytes
/
code.ps1
File metadata and controls
22 lines (21 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$arg = $args[0]
$path = $MyInvocation.MyCommand.Path | Split-Path -Parent | %{ Join-Path $_ list.xml }
$list = ([xml](Get-Content $path)).chcp.entity
if (!$arg) {
chcp
} elseif ($arg -match '^/([h\?]|help)$') {
Write-Host "`nCODE: simple chcp wrapper`n" -ForegroundColor DarkGreen
Write-Host "usage" -ForegroundColor Magenta
Write-Host "code key`n"
Write-Host "available keys (defined in $path)" -ForegroundColor Magenta
foreach ($e in $list) {
Write-Host "- $($e.key) (code: $($e.value))"
}
} else {
$code = $list | ?{ $_.key -eq $arg } | %{$_.value}
if ($code) {
chcp @($code)[0]
} else {
Write-Host "code error: unknown key $arg"
}
}