Skip to content

Conversation

@Gussy
Copy link

@Gussy Gussy commented Oct 3, 2025

This PR adds support for custom progress writers, allowing consumers of the Go package to implement their own progress reporting while maintaining full backward compatibility.

A new (global) --quiet flag that will silence verbose output as discussed in #117

One of my use-cases is to use the go-pmtiles package in an automated extract generating service. Right now I have some hacky code to parse the ASCII progressbar and convert that into a data structure that I can use to monitor and track extract progress.

API Changes

New Public Functions

// Set custom progress writer (nil disables progress)
pmtiles.SetProgressWriter(writer ProgressWriter)

// Interfaces for custom implementations
type ProgressWriter interface {
    NewCountProgress(total int64, description string) Progress
    NewBytesProgress(total int64, description string) Progress
}

type Progress interface {
    io.Writer
    Add(num int)
    Close() error
}

// Set quiet mode to reduce verbose output
pmtiles.SetQuietMode(true)

Breaking Changes

None. This is purely additive - all existing code continues to work unchanged.

Future work

#117 also mentions slog which would be a nice change, however to implement this cleanly the public APIs would need to change from accepting an log.Logger to an slog.Logger. I chose not to include that in this PR to avoid making any breaking public API changes. There are ways to wrap and override log.Logger to not break the API, but I didn't want to go down that (messy) path without maintainer encouragement.

Overall there's a lot of CLI-like logic that could be pulled out of pmtiles/ into the main.go CLI that would improve the go-pmtiles package ergonomics. The progress writer felt like a good place to start. The next one that would be useful to me is the Show() API, to programmatically get a struct of metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant