forked from github-linguist/linguist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42c68f2
commit 203f6d1
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
$)C# | ||
# Out-AnsiGraph.psm1 | ||
# Author: xcud | ||
# History: | ||
# v0.1 September 21, 2009 initial version | ||
# | ||
# PS Example> ps | select -first 5 | sort -property VM | | ||
# Out-AnsiGraph ProcessName, VM | ||
# AEADISRV 14508032 | ||
# audiodg 50757632 | ||
# conhost 73740288 | ||
# AppleMobileDeviceService 92061696 | ||
# btdna 126443520 | ||
# | ||
function Out-AnsiGraph($Parameter1=$null) { | ||
BEGIN { | ||
$q = new-object Collections.queue | ||
$max = 0; $namewidth = 0; | ||
} | ||
|
||
PROCESS { | ||
if($_) { | ||
$name = $_.($Parameter1[0]); | ||
$val = $_.($Parameter1[1]) | ||
if($max -lt $val) { $max = $val} | ||
if($namewidth -lt $name.length) { | ||
$namewidth = $name.length } | ||
$q.enqueue(@($name, $val)) | ||
} | ||
} | ||
|
||
END { | ||
$q | %{ | ||
$graph = ""; 0..($_[1]/$max*20) | | ||
%{ $graph += "" } | ||
$name = "{0,$namewidth}" -f $_[0] | ||
"$name $graph " + $_[1] | ||
} | ||
|
||
} | ||
} | ||
|
||
Export-ModuleMember Out-AnsiGraph |