Skip to content

Commit

Permalink
early return
Browse files Browse the repository at this point in the history
  • Loading branch information
raulb committed Jan 16, 2025
1 parent c2e2eb2 commit e0f30dc
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions cmd/conduit/root/pipelines/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,31 @@ func (c *ListCommand) ExecuteWithClient(ctx context.Context, client *api.Client)
}

func displayPipelines(pipelines []*apiv1.Pipeline) {
if len(pipelines) != 0 {
table := simpletable.New()

table.Header = &simpletable.Header{
Cells: []*simpletable.Cell{
{Align: simpletable.AlignCenter, Text: "ID"},
{Align: simpletable.AlignCenter, Text: "STATE"},
{Align: simpletable.AlignCenter, Text: "CREATED"},
{Align: simpletable.AlignCenter, Text: "LAST_UPDATED"},
},
}
if len(pipelines) == 0 {
return
}

for _, p := range pipelines {
r := []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: p.Id},
{Align: simpletable.AlignLeft, Text: p.State.Status.String()},
{Align: simpletable.AlignLeft, Text: p.CreatedAt.AsTime().String()},
{Align: simpletable.AlignLeft, Text: p.UpdatedAt.AsTime().String()},
}
table := simpletable.New()

table.Body.Cells = append(table.Body.Cells, r)
table.Header = &simpletable.Header{
Cells: []*simpletable.Cell{
{Align: simpletable.AlignCenter, Text: "ID"},
{Align: simpletable.AlignCenter, Text: "STATE"},
{Align: simpletable.AlignCenter, Text: "CREATED"},
{Align: simpletable.AlignCenter, Text: "LAST_UPDATED"},
},
}

for _, p := range pipelines {
r := []*simpletable.Cell{
{Align: simpletable.AlignRight, Text: p.Id},
{Align: simpletable.AlignLeft, Text: p.State.Status.String()},
{Align: simpletable.AlignLeft, Text: p.CreatedAt.AsTime().String()},
{Align: simpletable.AlignLeft, Text: p.UpdatedAt.AsTime().String()},
}
table.SetStyle(simpletable.StyleCompact)
fmt.Println(table.String())

table.Body.Cells = append(table.Body.Cells, r)
}
table.SetStyle(simpletable.StyleCompact)
fmt.Println(table.String())
}

0 comments on commit e0f30dc

Please sign in to comment.