mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
fix: use Console::Write for progress bar to avoid duplicate bars when piped via iex
Agent-Logs-Url: https://github.com/MCCTeam/Minecraft-Console-Client/sessions/2c598307-7028-46d4-ac37-045f5ce125ed Co-authored-by: milutinke <441903+milutinke@users.noreply.github.com>
This commit is contained in:
parent
46fdd687c7
commit
f10556a162
1 changed files with 7 additions and 2 deletions
|
|
@ -64,7 +64,12 @@ try {
|
|||
$bar = $filled.PadRight(50)
|
||||
$recv = [math]::Round($totalRead / 1MB, 1)
|
||||
$total = [math]::Round($totalBytes / 1MB, 1)
|
||||
Write-Host -NoNewline ("`r[{0}] {1,3}% {2,6:N1} / {3,6:N1} MB" -f $bar, $pct, $recv, $total)
|
||||
# Use [Console]::Write with an explicit \r so the cursor returns to
|
||||
# column 0 and overwrites the previous bar. Write-Host -NoNewline
|
||||
# does not reliably reposition the cursor when the script is run
|
||||
# via iex (pipe mode), producing multiple bars on one line.
|
||||
$line = "`r[{0}] {1,3}% {2,6:N1} / {3,6:N1} MB" -f $bar, $pct, $recv, $total
|
||||
[Console]::Write($line)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -73,7 +78,7 @@ try {
|
|||
$response.Close()
|
||||
}
|
||||
|
||||
Write-Host "" # end the progress line
|
||||
[Console]::WriteLine() # end the progress line
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Downloaded: .\$OUTPUT"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue