Skip to content

Conversation

@ilvsx
Copy link

@ilvsx ilvsx commented Dec 27, 2025

Summary

This PR exports the Bar field in the Downloader struct by changing it from bar (unexported) to Bar (exported). This allows external packages to access the progress bar instance for custom progress tracking and monitoring purposes.

Motivation

When using lux as a library (rather than a CLI tool), developers may need to:

  • Monitor download progress programmatically
  • Integrate download progress into their own UI/dashboard
  • Implement custom progress reporting (e.g., sending progress updates via WebSocket, logging to external services)
  • Build wrapper applications that need real-time download status

Previously, the bar field was unexported, making it impossible for external packages to access the progress bar state. This change enables these use cases while maintaining full backward compatibility.

Changes

  • File: downloader/downloader.go
  • Change: Renamed bar field to Bar in the Downloader struct
  • Impact: All internal references updated from downloader.bar to downloader.Bar

Code Change

// Before
type Downloader struct {
    bar    *pb.ProgressBar
    option Options
}

// After
type Downloader struct {
    Bar    *pb.ProgressBar
    option Options
}

Usage Example

import (
    "github.com/iawia002/lux/downloader"
)

func main() {
    d := downloader.New(downloader.Options{})

    // Start download in goroutine
    go d.Download(data)

    // Access progress bar for custom monitoring
    if d.Bar != nil {
        current := d.Bar.Current()
        total := d.Bar.Total()
        // Custom progress handling...
    }
}

Backward Compatibility

This change is fully backward compatible:
- No existing public APIs are modified
- No function signatures are changed
- Existing CLI usage remains unaffected
- Only adds new capability for library users

Testing

- Existing tests pass
- Manual testing of download functionality
- Progress bar displays correctly during downloads

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