package app import ( "context" c "cnb.cool/cnb/go-cnb/cnb" "cnb.cool/looc/git-cnb/cnb" "cnb.cool/looc/git-cnb/ui" "github.com/spf13/cobra" ) var ReleasesCmd = &cobra.Command{ Use: "release", Short: "print release of this repo", Long: "print release of this repo", Run: func(cmd *cobra.Command, args []string) { ListReleases(cmd.Context()) }, } func ListReleases(ctx context.Context) { releases, err := cnb.ListReleases(ctx, Client, Repo) if err != nil { ui.ErrorWithExit(err.Error()) } table := &ui.Table{ Titles: []ui.TableTitle{}, Items: [][]string{}, } table.Titles = []ui.TableTitle{ {Title: "TITLE", Width: 15}, {Title: "TYPE", Width: 15}, {Title: "TAG NAME", Width: 15}, {Title: "PUBLISHED", Width: 30}, } addReleasesToTable(table, releases) table.Print() } func addReleasesToTable(table *ui.Table, releases []c.Release) { for _, release := range releases { table.Items = append(table.Items, []string{ release.Name, "tt", release.TagName, release.PublishedAt}) } }