Skip to content

Commit

Permalink
Hide progress bar in non-interactive mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kotori2 committed Sep 21, 2023
1 parent 64c5cc9 commit d718d96
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions cmd/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,24 @@ func downloadCmd() *cobra.Command {
}
}

progress := progressbar.NewOptions64(1,
progressbar.OptionSetDescription("downloading"),
progressbar.OptionSetWriter(os.Stdout),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWidth(20),
progressbar.OptionFullWidth(),
progressbar.OptionThrottle(65*time.Millisecond),
progressbar.OptionShowCount(),
progressbar.OptionClearOnFinish(),
progressbar.OptionSpinnerType(14),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetElapsedTime(false),
progressbar.OptionSetPredictTime(false),
)
interactive, _ := cmd.Context().Value("interactive").(bool)
var progress *progressbar.ProgressBar
if interactive {
progress = progressbar.NewOptions64(1,
progressbar.OptionSetDescription("downloading"),
progressbar.OptionSetWriter(os.Stdout),
progressbar.OptionShowBytes(true),
progressbar.OptionSetWidth(20),
progressbar.OptionFullWidth(),
progressbar.OptionThrottle(65*time.Millisecond),
progressbar.OptionShowCount(),
progressbar.OptionClearOnFinish(),
progressbar.OptionSpinnerType(14),
progressbar.OptionSetRenderBlankState(true),
progressbar.OptionSetElapsedTime(false),
progressbar.OptionSetPredictTime(false),
)
}

out, err := dependencies.AppStore.Download(appstore.DownloadInput{Account: acc, App: lookupResult.App, OutputPath: outputPath, Progress: progress})
if err != nil {
Expand Down

0 comments on commit d718d96

Please sign in to comment.