From 75f72125950f5b786efcde5f771725d2c250d76f Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Fri, 26 May 2023 12:34:08 +0200 Subject: [PATCH] Update list-coffee-prices.ps1 --- Scripts/list-coffee-prices.ps1 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Scripts/list-coffee-prices.ps1 b/Scripts/list-coffee-prices.ps1 index 7540c127..dea85ccc 100644 --- a/Scripts/list-coffee-prices.ps1 +++ b/Scripts/list-coffee-prices.ps1 @@ -11,24 +11,23 @@ Author: Markus Fleschutz | License: CC0 #> -function WriteBar { param([string]$Text, [float]$Value, [float]$Max) - Write-Host "$Text " -noNewline +function WriteHorizontalBar { param([float]$Value, [float]$Max) $Num = ($Value * 100.0) / $Max while ($Num -ge 1.0) { Write-Host "█" -noNewline; $Num -= 1.0 } if ($Num -ge 0.875) { - Write-Host -noNewLine "▉" + Write-Host "▉" -noNewline } elseif ($Num -ge 0.75) { - Write-Host -noNewLine "▊" + Write-Host "▊" -noNewline } elseif ($Num -ge 0.625) { - Write-Host -noNewLine "▋" + Write-Host "▋" -noNewline } elseif ($Num -ge 0.5) { - Write-Host -noNewLine "▌" + Write-Host "▌" -noNewline } elseif ($Num -ge 0.375) { - Write-Host -noNewLine "▍" + Write-Host "▍" -noNewline } elseif ($Num -ge 0.25) { - Write-Host -noNewLine "▎" + Write-Host "▎" -noNewline } elseif ($Num -ge 0.125) { - Write-Host -noNewLine "▏" + Write-Host "▏" -noNewline } Write-Host " $Value" } @@ -40,9 +39,9 @@ try { "---------------------------------------------------------------" foreach($item in $prices.data) { if ($Item.value -eq ".") { continue } - [string]$date = $item.date + Write-Host "$($item.date) " -noNewline [int]$value = $Item.value - WriteBar $date $value 300.0 + WriteHorizontalBar $value 350.0 } exit 0 # success } catch {