replace progress percentage with actual file size

This commit is contained in:
2026-03-04 23:58:11 -05:00
parent 3cac63ba82
commit 481c8d9bb6
4 changed files with 93 additions and 68 deletions

View File

@@ -1,19 +1,21 @@
package main
import (
"fmt"
"strings"
)
import "fmt"
// Helper function to create string pointer
func ptr(s string) *string {
return &s
}
const progressBarLength = 20
func renderProgressBar(percent float64) string {
filled := int(float64(progressBarLength) * percent / 100)
bar := strings.Repeat("█", filled) + strings.Repeat(" ", progressBarLength-filled)
return fmt.Sprintf("[%s] %.0f%%", bar, percent)
func formatBytes(b int) string {
switch {
case b >= 1<<30:
return fmt.Sprintf("%.1f GB", float64(b)/float64(1<<30))
case b >= 1<<20:
return fmt.Sprintf("%.1f MB", float64(b)/float64(1<<20))
case b >= 1<<10:
return fmt.Sprintf("%.1f KB", float64(b)/float64(1<<10))
default:
return fmt.Sprintf("%d B", b)
}
}