mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
Update list-coffee-prices.ps1
This commit is contained in:
parent
1cd755a378
commit
75f7212595
@ -11,24 +11,23 @@
|
|||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
function WriteBar { param([string]$Text, [float]$Value, [float]$Max)
|
function WriteHorizontalBar { param([float]$Value, [float]$Max)
|
||||||
Write-Host "$Text " -noNewline
|
|
||||||
$Num = ($Value * 100.0) / $Max
|
$Num = ($Value * 100.0) / $Max
|
||||||
while ($Num -ge 1.0) { Write-Host "█" -noNewline; $Num -= 1.0 }
|
while ($Num -ge 1.0) { Write-Host "█" -noNewline; $Num -= 1.0 }
|
||||||
if ($Num -ge 0.875) {
|
if ($Num -ge 0.875) {
|
||||||
Write-Host -noNewLine "▉"
|
Write-Host "▉" -noNewline
|
||||||
} elseif ($Num -ge 0.75) {
|
} elseif ($Num -ge 0.75) {
|
||||||
Write-Host -noNewLine "▊"
|
Write-Host "▊" -noNewline
|
||||||
} elseif ($Num -ge 0.625) {
|
} elseif ($Num -ge 0.625) {
|
||||||
Write-Host -noNewLine "▋"
|
Write-Host "▋" -noNewline
|
||||||
} elseif ($Num -ge 0.5) {
|
} elseif ($Num -ge 0.5) {
|
||||||
Write-Host -noNewLine "▌"
|
Write-Host "▌" -noNewline
|
||||||
} elseif ($Num -ge 0.375) {
|
} elseif ($Num -ge 0.375) {
|
||||||
Write-Host -noNewLine "▍"
|
Write-Host "▍" -noNewline
|
||||||
} elseif ($Num -ge 0.25) {
|
} elseif ($Num -ge 0.25) {
|
||||||
Write-Host -noNewLine "▎"
|
Write-Host "▎" -noNewline
|
||||||
} elseif ($Num -ge 0.125) {
|
} elseif ($Num -ge 0.125) {
|
||||||
Write-Host -noNewLine "▏"
|
Write-Host "▏" -noNewline
|
||||||
}
|
}
|
||||||
Write-Host " $Value"
|
Write-Host " $Value"
|
||||||
}
|
}
|
||||||
@ -40,9 +39,9 @@ try {
|
|||||||
"---------------------------------------------------------------"
|
"---------------------------------------------------------------"
|
||||||
foreach($item in $prices.data) {
|
foreach($item in $prices.data) {
|
||||||
if ($Item.value -eq ".") { continue }
|
if ($Item.value -eq ".") { continue }
|
||||||
[string]$date = $item.date
|
Write-Host "$($item.date) " -noNewline
|
||||||
[int]$value = $Item.value
|
[int]$value = $Item.value
|
||||||
WriteBar $date $value 300.0
|
WriteHorizontalBar $value 350.0
|
||||||
}
|
}
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
|
Loading…
Reference in New Issue
Block a user