Skip to content

Commit

Permalink
[tui] Revamp downloads
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Wies <evan@neomantra.net>
  • Loading branch information
neomantra committed Jan 22, 2025
1 parent 6c37ed2 commit e005232
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 336 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v0.2.2 (2025-01-21)

* `dbn-go-tui` improvements:
* Add `--limit` argument to control concurrent downloads
* Add pretty progress bars and table
* Fix queueing of duplicate files
* Fix honoring of max active downloads

## v0.2.1 (2025-01-15)

* Fix `dbn-go-file` was not included in relase.
Expand Down
13 changes: 12 additions & 1 deletion cmd/dbn-go-hist/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

///////////////////////////////////////////////////////////////////////////////

const defaultMaxActiveDownloads = 4

var (
databentoApiKey string

Expand All @@ -42,6 +44,8 @@ var (
encoding dbn.Encoding = dbn.Encoding_Dbn
compression dbn.Compression = dbn.Compress_ZStd

maxActiveDownloads int = defaultMaxActiveDownloads

jobID string
stateFilter string

Expand Down Expand Up @@ -301,6 +305,7 @@ func main() {
resolveCmd.MarkFlagRequired("start")

rootCmd.AddCommand(tuiCmd)
tuiCmd.Flags().IntVarP(&maxActiveDownloads, "limit", "l", defaultMaxActiveDownloads, "Limit maximum concurrent downloads")

err := rootCmd.Execute()
requireNoError(err)
Expand Down Expand Up @@ -640,8 +645,14 @@ var tuiCmd = &cobra.Command{
Args: cobra.ArbitraryArgs,
Run: func(cmd *cobra.Command, args []string) {
config := dbn_tui.Config{
DatabentoApiKey: requireDatabentoApiKey(),
DatabentoApiKey: requireDatabentoApiKey(),
MaxActiveDownloads: maxActiveDownloads,
}
if config.MaxActiveDownloads < 0 {
fmt.Fprintf(os.Stderr, "--limit cannot be negative\n")
return
}

err := dbn_tui.Run(config)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
Expand Down
8 changes: 8 additions & 0 deletions cmd/dbn-go-tui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/spf13/pflag"
)

const defaultMaxActiveDownloads = 4

///////////////////////////////////////////////////////////////////////////////

func main() {
Expand All @@ -18,6 +20,7 @@ func main() {

pflag.BoolVarP(&showHelp, "help", "h", false, "Show help")
pflag.StringVarP(&config.DatabentoApiKey, "key", "k", "", "Databento API key (or set 'DATABENTO_API_KEY' envvar)")
pflag.IntVarP(&config.MaxActiveDownloads, "limit", "l", defaultMaxActiveDownloads, "Limit maximum concurrent downloads")
pflag.Parse()

if showHelp {
Expand All @@ -34,6 +37,11 @@ func main() {
}
}

if config.MaxActiveDownloads < 0 {
fmt.Fprintf(os.Stderr, "--limit cannot be negative\n")
return
}

err := dbn_tui.Run(config)
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.23.3
toolchain go1.23.4

require (
github.com/76creates/stickers v1.4.1
github.com/apache/arrow-go/v18 v18.1.0
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.2.4
Expand All @@ -30,6 +31,7 @@ require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/charmbracelet/harmonica v0.2.0 // indirect
github.com/charmbracelet/x/ansi v0.4.5 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20241022174419-46d9bb99a691 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/76creates/stickers v1.4.1 h1:cd9qM1+FuM7TFStTRxEMEWNpyCY5CIJ05xvKdA+fwk4=
github.com/76creates/stickers v1.4.1/go.mod h1:S0ii0IRGMJx5n5zGpesai8oX0DWY3X5PDI3OUErgF38=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c h1:RGWPOewvKIROun94nF7v2cua9qP+thov/7M50KEoeSU=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
Expand All @@ -20,6 +22,8 @@ github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQW
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea v1.2.4 h1:KN8aCViA0eps9SCOThb2/XPIlea3ANJLUkv3KnQRNCE=
github.com/charmbracelet/bubbletea v1.2.4/go.mod h1:Qr6fVQw+wX7JkWWkVyXYk/ZUQ92a6XNekLXa3rR18MM=
github.com/charmbracelet/harmonica v0.2.0 h1:8NxJWRWg/bzKqqEaaeFNipOu77YR5t8aSwG4pgaUBiQ=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/huh v0.6.0 h1:mZM8VvZGuE0hoDXq6XLxRtgfWyTI3b2jZNKh0xWmax8=
github.com/charmbracelet/huh v0.6.0/go.mod h1:GGNKeWCeNzKpEOh/OJD8WBwTQjV3prFAtQPpLv+AVwU=
github.com/charmbracelet/lipgloss v1.0.0 h1:O7VkGDvqEdGi93X+DeqsQ7PKHDgtQfF8j8/O2qFMQNg=
Expand Down
2 changes: 1 addition & 1 deletion internal/tui/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func getSchemas(databentoApiKey string, dataset string) tea.Cmd {
(*destMap)[schema] = cost
}
}
for schema, _ := range schemasMap {
for schema := range schemasMap {
msg.Schemas = append(msg.Schemas, schema)
}
return msg
Expand Down
Loading

0 comments on commit e005232

Please sign in to comment.