forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-tiobe-index.ps1
59 lines (56 loc) · 1.51 KB
/
list-tiobe-index.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<#
.SYNOPSIS
Lists the TIOBE index of top programming languages
.DESCRIPTION
This script lists the TIOBE index of top programming languages.
.EXAMPLE
PS> ./list-tiobe-index
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
#>
function WriteBar { param([string]$Text, [float]$Value, [float]$Max, [float]$Change)
$Num = ($Value * 100.0) / $Max
while ($Num -ge 1.0) {
write-host -noNewLine "█"
$Num -= 1.0
}
if ($Num -ge 0.875) {
write-host -noNewLine "▉"
} elseif ($Num -ge 0.75) {
write-host -noNewLine "▊"
} elseif ($Num -ge 0.625) {
write-host -noNewLine "▋"
} elseif ($Num -ge 0.5) {
write-host -noNewLine "▌"
} elseif ($Num -ge 0.375) {
write-host -noNewLine "▍"
} elseif ($Num -ge 0.25) {
write-host -noNewLine "▎"
} elseif ($Num -ge 0.125) {
write-host -noNewLine "▏"
}
write-host -noNewLine " $Text $($Value)%"
if ($Change -ge 0.0) {
write-host -foregroundColor green " +$($Change)%"
} else {
write-host -foregroundColor red " $($Change)%"
}
}
try {
& write-big.ps1 "TIOBE INDEX 2021-06"
" Source: https://www.tiobe.com"
""
$Table = import-csv "$PSScriptRoot/../Data/TIOBE-index.csv"
foreach($Row in $Table) {
[string]$Name = $Row.Language
[float]$Value = $Row.Popularity
[float]$Change = $Row.Change
WriteBar $Name $Value 14.0 $Change
}
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}