- 
                Notifications
    You must be signed in to change notification settings 
- Fork 69
Show current worker goroutine status below progress bar #338
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
Conversation
| Timestamps truncated and moved to the right. TODOs checked off. Ready for the big review @sourcegraph/campaigns! | 
| if !o.caps.Isatty { | ||
| newProgressWithStatusBarsSimple(barPtrs, statusBars, o) | ||
| } | ||
|  | ||
| return newProgressWithStatusBarsTTY(barPtrs, statusBars, o, opts) | 
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.
Note to reviewers: progressWithStatusbarsTTY and progressWithSatusBarsSimple have a lot of similarities with progressTTY and progressSimple respectively. I've tried to extract some of the common stuff and embed progressTTY in progressWithStatusBarsTTY. That helped but not as much as it would've in a language where inheritance was a first class concept.
The problem in Go is this:
type inner struct {
	name string
}
func (i *inner) String() string { return i.format() }
func (i *inner) format() string { return fmt.Sprintf("my name is %s", i.name) }
type outer struct {
	*inner
}
func (o *outer) format() string { return "i am outer!" }
func main() {
	i := &inner{name: "inner"}
	fmt.Println(i)
	o := &outer{inner: i}
	fmt.Println(o)
}That prints:
my name is inner
my name is inner
See this StackOverflow answer for details. Short version: Go doesn't have virtual methods.
I might try to "invert" the code and have the structs' methods call functions, passing themselves in, but I'm not sure it's worth it.
Because right now I don't think the duplication is a problem. The code that is duplicated depends on the callee's state and doesn't contain a lot of duplicated logic. The hairy bits are not duplicated.
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.
Looks good! Thanks for taking on the effort of designing a TUI 👍
| StartedAt time.Time | ||
| FinishedAt time.Time | ||
|  | ||
| // TODO: add current step and progress fields. | 
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.
is this todo comment related to the newly added line? If not, I'd add a newline here to avoid confusion
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'll let @LawnGnome decide. He added the TODO and I wasn't sure whether he had something else in mind, like
TotalSteps int
CurrentStep intor something like that.
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.
That was my intention, but I think it's unnecessary now with the work that you've done since I wrote that, so we could remove the TODO.
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.
LGTM, 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.
| StartedAt time.Time | ||
| FinishedAt time.Time | ||
|  | ||
| // TODO: add current step and progress fields. | 
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.
That was my intention, but I think it's unnecessary now with the work that you've done since I wrote that, so we could remove the TODO.
| } | ||
|  | ||
| if !o.caps.Isatty { | ||
| newProgressWithStatusBarsSimple(barPtrs, statusBars, o) | 
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.
This doesn't actually return the simple version, which means that ANSI escape codes are still used and the output (if being redirected to a file) is unusable.
However, progressWithStatusBarsSimple doesn't implement ProgressWithStatusBars at the moment, so that's another issue that would have to be dealt with.
I've pushed 19b6ec5 with what I think would be a reasonable fix, but haven't merged it into this branch: PTAL!
Co-authored-by: Adam Harvey <aharvey@sourcegraph.com>
* First try to add progress with status bars * Refactoring and renaming * Tiny step and refactoring * Get ProgressWithStatusBars working * Change API of progressWithStatusbars * Refactor StatusBar printing * Embed ProgressTTY in ProgressWithStatusBarsTTY * More merging of progressTTY and progressWithStatusbarsTTY * Add simple progress with status bars * Move demo of progress with bars to _examples * Restore overwritten methods * Restore more overwritten methods * Restore another overwritten method * WIP: Wire up status bars with executor * Print status bars below progress bar and add ASCII box characters * WIP1: Introduce campaign progress printer * WIP2: More refactoring of campaign status printing * More cleanup and refactoring * Change styling of progress bar with status * Add time to StatusBar and display right-aligned * Use a const * Add CHANGELOG entry * Ignore invisible characters for text length in progress bar * Update CHANGELOG.md Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Erase previous content with spaces on blank line * Thin box drawing lines * Improve non-TTY output for progress indicators with status bars. Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name>
* Add 'campaigns new' command * Print success message * Update cmd/src/campaigns_new.go Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Show current worker goroutine status below progress bar (#338) * First try to add progress with status bars * Refactoring and renaming * Tiny step and refactoring * Get ProgressWithStatusBars working * Change API of progressWithStatusbars * Refactor StatusBar printing * Embed ProgressTTY in ProgressWithStatusBarsTTY * More merging of progressTTY and progressWithStatusbarsTTY * Add simple progress with status bars * Move demo of progress with bars to _examples * Restore overwritten methods * Restore more overwritten methods * Restore another overwritten method * WIP: Wire up status bars with executor * Print status bars below progress bar and add ASCII box characters * WIP1: Introduce campaign progress printer * WIP2: More refactoring of campaign status printing * More cleanup and refactoring * Change styling of progress bar with status * Add time to StatusBar and display right-aligned * Use a const * Add CHANGELOG entry * Ignore invisible characters for text length in progress bar * Update CHANGELOG.md Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Erase previous content with spaces on blank line * Thin box drawing lines * Improve non-TTY output for progress indicators with status bars. Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name> * Incorporate feedback * Change placeholders in campaign skeleton Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name>
* First try to add progress with status bars * Refactoring and renaming * Tiny step and refactoring * Get ProgressWithStatusBars working * Change API of progressWithStatusbars * Refactor StatusBar printing * Embed ProgressTTY in ProgressWithStatusBarsTTY * More merging of progressTTY and progressWithStatusbarsTTY * Add simple progress with status bars * Move demo of progress with bars to _examples * Restore overwritten methods * Restore more overwritten methods * Restore another overwritten method * WIP: Wire up status bars with executor * Print status bars below progress bar and add ASCII box characters * WIP1: Introduce campaign progress printer * WIP2: More refactoring of campaign status printing * More cleanup and refactoring * Change styling of progress bar with status * Add time to StatusBar and display right-aligned * Use a const * Add CHANGELOG entry * Ignore invisible characters for text length in progress bar * Update CHANGELOG.md Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Erase previous content with spaces on blank line * Thin box drawing lines * Improve non-TTY output for progress indicators with status bars. Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name>
* Add 'campaigns new' command * Print success message * Update cmd/src/campaigns_new.go Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Show current worker goroutine status below progress bar (#338) * First try to add progress with status bars * Refactoring and renaming * Tiny step and refactoring * Get ProgressWithStatusBars working * Change API of progressWithStatusbars * Refactor StatusBar printing * Embed ProgressTTY in ProgressWithStatusBarsTTY * More merging of progressTTY and progressWithStatusbarsTTY * Add simple progress with status bars * Move demo of progress with bars to _examples * Restore overwritten methods * Restore more overwritten methods * Restore another overwritten method * WIP: Wire up status bars with executor * Print status bars below progress bar and add ASCII box characters * WIP1: Introduce campaign progress printer * WIP2: More refactoring of campaign status printing * More cleanup and refactoring * Change styling of progress bar with status * Add time to StatusBar and display right-aligned * Use a const * Add CHANGELOG entry * Ignore invisible characters for text length in progress bar * Update CHANGELOG.md Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> * Erase previous content with spaces on blank line * Thin box drawing lines * Improve non-TTY output for progress indicators with status bars. Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name> * Incorporate feedback * Change placeholders in campaign skeleton Co-authored-by: Adam Harvey <aharvey@sourcegraph.com> Co-authored-by: Adam Harvey <adam@adamharvey.name>

GIF:
TODO: