Skip to content

Commit

Permalink
feat(processtree): Introduce WithHideOnSuccess option (#934)
Browse files Browse the repository at this point in the history
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
  • Loading branch information
craciunoiuc committed Oct 26, 2023
2 parents 4066d0e + 55cfb30 commit 190f42b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tui/processtree/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ func WithFailFast(failFast bool) ProcessTreeOption {
return nil
}
}

func WithHideOnSuccess(hide bool) ProcessTreeOption {
return func(pt *ProcessTree) error {
pt.hide = hide
return nil
}
}
1 change: 1 addition & 0 deletions tui/processtree/processtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type ProcessTree struct {
errChan chan error
failFast bool
oldOut iostreams.FileWriter
hide bool
}

func NewProcessTree(ctx context.Context, opts []ProcessTreeOption, tree ...*ProcessTreeItem) (*ProcessTree, error) {
Expand Down
4 changes: 4 additions & 0 deletions tui/processtree/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func (pt ProcessTree) View() string {
}

func (stm ProcessTree) printItem(pti *ProcessTreeItem, offset uint) string {
if pti.status == StatusSuccess && stm.hide {
return ""
}

failed := 0
completed := 0
running := 0
Expand Down

0 comments on commit 190f42b

Please sign in to comment.