Skip to content

Commit

Permalink
fix(progressbar/command.go): dummy OnProgressCmd if not passed. Usefu…
Browse files Browse the repository at this point in the history
…l for demos
  • Loading branch information
indaco committed Nov 23, 2022
1 parent 095ac91 commit 8772874
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions progressbar/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ func (cfg *Config) setDefaults() {
cfg.OnCompletesMsg = "Done!"
}

cfg.OnProgressCmd = func(item string) tea.Cmd {
// This is where you'd do i/o stuff to download and install packages. In
// our case we're just pausing for a moment to simulate the process.
d := time.Millisecond * time.Duration(rand.Intn(500))
return tea.Tick(d, func(t time.Time) tea.Msg {
return IncrementMsg(item)
})
if cfg.OnProgressCmd == nil {
cfg.OnProgressCmd = func(item string) tea.Cmd {
// This is where you'd do i/o stuff to download and install packages. In
// our case we're just pausing for a moment to simulate the process.
d := time.Millisecond * time.Duration(rand.Intn(500))
return tea.Tick(d, func(t time.Time) tea.Msg {
return IncrementMsg(item)
})
}
}
}

Expand Down

0 comments on commit 8772874

Please sign in to comment.