Files
StarPilot/mapd_repo/cli/download_progress.go
firestar5683 ab81464bd1 Maps
Add navigation and map matching providers with the vendored map service sources.

Co-authored-by: Daniel Koepping <elkoled@gmail.com>
Co-authored-by: Danny <dannyirwin31@yahoo.com>
Co-authored-by: Prabhaav Pillai <prabhaav@msu.edu>
Co-authored-by: dirwin31 <83434411+dirwin31@users.noreply.github.com>
2026-10-14 19:56:17 -05:00

52 lines
990 B
Go

package cli
import (
"fmt"
tea "github.com/charmbracelet/bubbletea"
"pfeifer.dev/mapd/cereal/custom"
)
type downloadProgressModel struct {
output custom.MapdExtendedOut
valid bool
}
func (m downloadProgressModel) Update(msg tea.Msg, mm *uiModel) (downloadProgressModel, tea.Cmd) {
m.valid = mm.extendedDataValid
m.output = mm.extendedData
return m, nil
}
func (m downloadProgressModel) View() string {
if !m.valid {
return ""
}
progress, err := m.output.DownloadProgress()
if err != nil {
return ""
}
locations := ""
l, err := progress.Locations()
if err == nil {
for i := range l.Len() {
str, err := l.At(i)
if err == nil {
locations += str
if i < l.Len()-1 {
locations += ","
}
}
}
}
return docStyle.Render(fmt.Sprintf(
"locations: %s\nactive %t\ncancelled %t\ntotal files: %d\ndownloaded files: %d",
locations,
progress.Active(),
progress.Cancelled(),
progress.TotalFiles(),
progress.DownloadedFiles(),
) + "\n")
}