New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: custom writer for progressbar and spinner printers #337
feat: custom writer for progressbar and spinner printers #337
Conversation
Codecov Report
@@ Coverage Diff @@
## master #337 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 1505 1509 +4
=========================================
+ Hits 1505 1509 +4
Continue to review full report at Codecov.
|
|[Add(count int)](https://pkg.go.dev/github.com/pterm/pterm#TemplatePrinter.Add)|Add `count` to current value.| | ||
|[GetElapsedTime()](https://pkg.go.dev/github.com/pterm/pterm#TemplatePrinter.GetElapsedTime)|GetElapsedTime returns the elapsed time, since the ProgressbarPrinter was started.| | ||
|[Increment()](https://pkg.go.dev/github.com/pterm/pterm#TemplatePrinter.Increment)|Increment current value by one.| | ||
|[UpdateTitle(title string)](https://pkg.go.dev/github.com/pterm/pterm#TemplatePrinter.UpdateTitle)|Update the progressbar's title.| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These links seemed wrong so I updated them too :)
Exactly what I need! Was actually considering doing this myself. 👍 |
Hi @Brookke, thanks for the PR! Could you maybe add some tests to ensure, the output is actually written to the given writer? You can do that with testza: https://github.com/MarvinJWendt/testza#capturestderr You could use the writer in the callback function to write to and assert the output contains a word you put into the progressbar / spinner title. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more unit tests, that capture the output and ensure that a specific writer is used, are missing. If you need help with testza, just ping me here or on Discord :)
@MarvinJWendt I have added some tests for the spinner printer, and I will do the same for the progress bar soon. However I had to add time.sleeps in order to wait for the go routines to run, which isn't great. If you have any other suggestions do let me know |
Additionally it looks like the tests fail on ubuntu, I will investigate why |
The CI-System takes ages to complete already, so I don't think the second delay is a problem, as I also can't think of an easy solution. |
@MarvinJWendt great thanks, I'll do the same for the progress back early next week, currently on holiday :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you enjoyed your holidays! The PR looks good to me!
Description
Adds a custom writer to the progress bar and spinner components.
Scope
Related Issue
Fixes #261
To-Do Checklist