-
Notifications
You must be signed in to change notification settings - Fork 587
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
Split UI from event handling #448
Conversation
Signed-off-by: Alex Goodman <wagoodman@gmail.com>
Benchmark Test ResultsBenchmark results from the latest changes vs base branch
|
Signed-off-by: Alex Goodman <wagoodman@gmail.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
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.
Thanks! 🎉
cmd/packages.go
Outdated
ux := ui.Select(appConfig.CliOptions.Verbosity > 0, appConfig.Quiet) | ||
return ux(errs, eventSubscription) | ||
return eventLoop( | ||
packagesExecWorker(args[0]), |
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.
nit: If we're passing in a specific arg, it could be a nice hint to the reader to identify the arg via an explicit parameter for packagesExec
, rather than receive the whole slice and grab item 0
just in time.
@@ -21,6 +21,7 @@ require ( | |||
github.com/gookit/color v1.2.7 | |||
github.com/hashicorp/go-multierror v1.1.0 | |||
github.com/hashicorp/go-version v1.2.0 | |||
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 |
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.
Just double-checking that this was intended, since I couldn't remember if we're adding new ANSI logic here.
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've used this package before and decided to use it for the hide/show of the cursor (was intended)
ui/event_handlers.go
Outdated
const statusSet = common.SpinnerDotSet // SpinnerCircleOutlineSet | ||
const completedStatus = "✔" // "●" | ||
const statusSet = components.SpinnerDotSet // SpinnerCircleOutlineSet | ||
const completedStatus = "✔" // "●" |
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.
Just curious: What is "●"
for?
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 can remove this --it was used during early development when I was flopping between options
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
* split UI from event handling Signed-off-by: Alex Goodman <wagoodman@gmail.com> * add event loop tests Signed-off-by: Alex Goodman <wagoodman@gmail.com> * use stereoscope cleanup function during signal handling Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * correct error wrapping in packages cmd Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * migrate ui event handlers to ui package Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * clarify command worker input var + remove dead comments Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Today the event loop is coupled with the specific UI details, which is not ideal. This PR splits out those concerns, migrating the event loop from the
ui
package tocmd
and extracting theui.UI
function into an interface for setting up a UI, handling individual events from the event loop, and tearing down the UI. This allows for flow control, signal handling, and worker/event management to be shared, and the UI specifics to be implemented behind an interface --this allows for the ability to swap out the ETUI implementation for the logger implementation, but now without duplicating flow control logic.Closes #416