Skip to content

Commit d549e63

Browse files
Merge pull request #582 from yamamoto-febc/fix/v1/progress
Fixed progress termination process
2 parents c5e698e + 6e49ea7 commit d549e63

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/cmd/core/command.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ func (c *Command) exec(ctx cli.Context, ids cli.ResourceContexts) (output.Conten
376376
fn := c.Func
377377
c.Func = func(ctx cli.Context, parameter interface{}) ([]interface{}, error) {
378378
var results []interface{}
379-
err := NewProgress(ctx).Exec(func() error {
379+
progress := NewProgress(ctx)
380+
defer progress.Close()
381+
err := progress.Exec(func() error {
380382
res, err := fn(ctx, parameter)
381383
if err != nil {
382384
return err

pkg/cmd/core/progress.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ func (p *Progress) msgFailed(err error) string {
9494

9595
func (p *Progress) Start() {
9696
p.doneCh = make(chan error)
97-
defer close(p.doneCh)
9897

9998
ticker := time.NewTicker(p.duration)
10099
defer ticker.Stop()
@@ -130,3 +129,7 @@ func (p *Progress) print(clr *color.Color, msg string) {
130129
p.printer.Fprint(p.out, clr, msg)
131130
p.printer.Fprint(p.out, color.New(color.Reset), "")
132131
}
132+
133+
func (p *Progress) Close() {
134+
close(p.doneCh)
135+
}

0 commit comments

Comments
 (0)