diff --git a/kusion.go b/kusion.go index e5188c3d..6ce5eb1b 100644 --- a/kusion.go +++ b/kusion.go @@ -16,7 +16,7 @@ func main() { if err := command.Execute(); err != nil { // Pretty-print the error and exit with an error. - pretty.Error.Println(err.Error()) + pretty.ErrorT.Println(err.Error()) os.Exit(1) } diff --git a/pkg/cmd/apply/options.go b/pkg/cmd/apply/options.go index 8c18ef55..d1e91978 100644 --- a/pkg/cmd/apply/options.go +++ b/pkg/cmd/apply/options.go @@ -257,7 +257,7 @@ func Apply( strings.ToLower(string(msg.OpResult)), ) } - pterm.Success.WithWriter(out).Println(title) + pretty.SuccessT.WithWriter(out).Printfln(title) progressbar.UpdateTitle(title) progressbar.Increment() ls.Count(changeStep.Action) @@ -267,7 +267,7 @@ func Apply( pterm.Bold.Sprint(changeStep.ID), strings.ToLower(string(msg.OpResult)), ) - pterm.Error.WithWriter(out).Printf("%s\n", title) + pretty.ErrorT.WithWriter(out).Printf("%s\n", title) default: title := fmt.Sprintf("%s %s %s", changeStep.Action.Ing(), @@ -307,6 +307,7 @@ func Apply( // wait for msgCh closed wg.Wait() // print summary + pterm.Println() pterm.Fprintln(out, fmt.Sprintf("Apply complete! Resources: %d created, %d updated, %d deleted.", ls.created, ls.updated, ls.deleted)) return nil } diff --git a/pkg/cmd/destroy/options.go b/pkg/cmd/destroy/options.go index 9420a569..9ee4cee0 100644 --- a/pkg/cmd/destroy/options.go +++ b/pkg/cmd/destroy/options.go @@ -19,6 +19,7 @@ import ( "kusionstack.io/kusion/pkg/engine/state" "kusionstack.io/kusion/pkg/log" "kusionstack.io/kusion/pkg/project" + "kusionstack.io/kusion/pkg/util/pretty" "kusionstack.io/kusion/pkg/util/signals" "kusionstack.io/kusion/pkg/workspace" ) @@ -191,7 +192,7 @@ func (o *Options) destroy(planResources *apiv1.Intent, changes *models.Changes, var deleted int // progress bar, print dag walk detail - progressbar, err := pterm.DefaultProgressbar.WithTotal(len(changes.StepKeys)).Start() + progressbar, err := pterm.DefaultProgressbar.WithMaxWidth(0).WithTotal(len(changes.StepKeys)).Start() if err != nil { return err } @@ -231,7 +232,7 @@ func (o *Options) destroy(planResources *apiv1.Intent, changes *models.Changes, strings.ToLower(string(msg.OpResult)), ) } - pterm.Success.Println(title) + pretty.SuccessT.Println(title) progressbar.UpdateTitle(title) progressbar.Increment() deleted++ @@ -241,7 +242,7 @@ func (o *Options) destroy(planResources *apiv1.Intent, changes *models.Changes, pterm.Bold.Sprint(changeStep.ID), strings.ToLower(string(msg.OpResult)), ) - pterm.Error.Printf("%s\n", title) + pretty.ErrorT.Printf("%s\n", title) default: title := fmt.Sprintf("%s %s %s", changeStep.Action.Ing(), diff --git a/pkg/engine/operation/models/change.go b/pkg/engine/operation/models/change.go index 92c4efc4..cbbf1e9f 100644 --- a/pkg/engine/operation/models/change.go +++ b/pkg/engine/operation/models/change.go @@ -165,16 +165,11 @@ func (p *Changes) AllUnChange() bool { func (p *Changes) Summary(writer io.Writer) { // Create a fork of the default table, fill it with data and print it. // Data can also be generated and inserted later. - tableHeader := []string{fmt.Sprintf("Stack: %s", p.stack.Name), "ID", "Action"} + tableHeader := []string{fmt.Sprintf("Stack: %s\nID", p.stack.Name), "\nAction"} tableData := pterm.TableData{tableHeader} - for i, step := range p.Values() { - itemPrefix := " * ├─" - if i == len(p.StepKeys)-1 { - itemPrefix = " * └─" - } - - tableData = append(tableData, []string{itemPrefix, step.ID, step.Action.String()}) + for _, step := range p.Values() { + tableData = append(tableData, []string{step.ID, step.Action.String()}) } _ = pterm.DefaultTable.WithHasHeader().