Skip to content

Commit

Permalink
feat: add apply print result
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 22, 2023
1 parent 9634cc4 commit 04f838e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions cmd/uniflow/apply/cmd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package apply

import (
"fmt"
"io"
"io/fs"

"github.com/oklog/ulid/v2"
"github.com/siyul-park/uniflow/cmd/flag"
"github.com/siyul-park/uniflow/cmd/printer"
"github.com/siyul-park/uniflow/cmd/resource"
"github.com/siyul-park/uniflow/internal/util"
"github.com/siyul-park/uniflow/pkg/database"
Expand All @@ -22,6 +24,31 @@ type (
}
)

var (
SpecTableColumnDefinitions = []printer.TableColumnDefinition{
{
Name: "id",
Format: "$.id",
},
{
Name: "kind",
Format: "$.kind",
},
{
Name: "name",
Format: "$.name",
},
{
Name: "namespace",
Format: "$.namespace",
},
{
Name: "links",
Format: "$.links",
},
}
)

func NewCmd(config Config) *cobra.Command {
sc := config.Scheme
db := config.Database
Expand Down Expand Up @@ -134,6 +161,19 @@ func NewCmd(config Config) *cobra.Command {
return err
}

tablePrinter, err := printer.NewTable(SpecTableColumnDefinitions)
if err != nil {
return err
}

table, err := tablePrinter.Print(specs)
if err != nil {
return err
}
if _, err := fmt.Fprint(cmd.OutOrStdout(), table); err != nil {
return err
}

return nil
},
}
Expand Down

0 comments on commit 04f838e

Please sign in to comment.