mirror of
https://github.com/anchore/syft.git
synced 2026-10-30 22:12:28 +01:00
Signed-off-by: Avi Deitcher <avi@deitcher.net> Signed-off-by: Keith Zantow <kzantow@gmail.com> Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Co-authored-by: Keith Zantow <kzantow@gmail.com> Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package event
|
|
|
|
import (
|
|
"github.com/wagoodman/go-partybus"
|
|
"github.com/wagoodman/go-progress"
|
|
|
|
"github.com/anchore/syft/internal/bus"
|
|
)
|
|
|
|
type CatalogerTask struct {
|
|
prog *progress.Manual
|
|
// Title
|
|
Title string
|
|
// TitleOnCompletion a string to use as title when completed
|
|
TitleOnCompletion string
|
|
// SubStatus indicates this progress should be rendered as a sub-item
|
|
SubStatus bool
|
|
// RemoveOnCompletion indicates this progress line will be removed when completed
|
|
RemoveOnCompletion bool
|
|
// value is the value to display -- not public as SetValue needs to be called to initialize this progress
|
|
value string
|
|
}
|
|
|
|
func (e *CatalogerTask) init() {
|
|
e.prog = progress.NewManual(-1)
|
|
|
|
bus.Publish(partybus.Event{
|
|
Type: CatalogerTaskStarted,
|
|
Source: e,
|
|
})
|
|
}
|
|
|
|
func (e *CatalogerTask) SetCompleted() {
|
|
if e.prog != nil {
|
|
e.prog.SetCompleted()
|
|
}
|
|
}
|
|
|
|
func (e *CatalogerTask) SetValue(value string) {
|
|
if e.prog == nil {
|
|
e.init()
|
|
}
|
|
e.value = value
|
|
}
|
|
|
|
func (e *CatalogerTask) GetValue() string {
|
|
return e.value
|
|
}
|
|
|
|
func (e *CatalogerTask) GetMonitor() *progress.Manual {
|
|
return e.prog
|
|
}
|