Skip to content

Commit

Permalink
feat: update kusion destroy progressbar (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 committed Apr 25, 2024
1 parent a3a2ac9 commit c19e172
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/cmd/destroy/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ func (o *DeleteOptions) destroy(planResources *apiv1.Spec, changes *models.Chang
progressbar, err := o.UI.ProgressbarPrinter.
WithMaxWidth(0).
WithTotal(len(changes.StepKeys)).
WithWriter(o.IOStreams.Out).
WithRemoveWhenDone().
Start()
if err != nil {
Expand Down Expand Up @@ -326,7 +327,7 @@ func (o *DeleteOptions) destroy(planResources *apiv1.Spec, changes *models.Chang
strings.ToLower(string(msg.OpResult)),
)
}
pretty.SuccessT.Println(title)
pretty.SuccessT.WithWriter(o.IOStreams.Out).Println(title)
progressbar.UpdateTitle(title)
progressbar.Increment()
deleted++
Expand All @@ -336,7 +337,7 @@ func (o *DeleteOptions) destroy(planResources *apiv1.Spec, changes *models.Chang
pterm.Bold.Sprint(changeStep.ID),
strings.ToLower(string(msg.OpResult)),
)
pretty.ErrorT.Printf("%s\n", title)
pretty.ErrorT.WithWriter(o.IOStreams.Out).Printf("%s\n", title)
default:
title := fmt.Sprintf("%s %s %s",
changeStep.Action.Ing(),
Expand Down Expand Up @@ -365,7 +366,7 @@ func (o *DeleteOptions) destroy(planResources *apiv1.Spec, changes *models.Chang
wg.Wait()
// print summary
pterm.Println()
pterm.Printf("Destroy complete! Resources: %d deleted.\n", deleted)
pterm.Fprintln(o.IOStreams.Out, fmt.Sprintf("Destroy complete! Resources: %d deleted.", deleted))
return nil
}

Expand Down

0 comments on commit c19e172

Please sign in to comment.