expose pipeline list options to cli

This commit is contained in:
Robert Kaussow 2024-04-27 19:42:47 +02:00
parent bf2dfd36e5
commit 58fec6049c
No known key found for this signature in database
GPG key ID: 4E692A2EAECC03C0
2 changed files with 24 additions and 2 deletions

View file

@ -17,6 +17,7 @@ package pipeline
import (
"os"
"text/template"
"time"
"github.com/urfave/cli/v2"
@ -50,6 +51,16 @@ var pipelineListCmd = &cli.Command{
Usage: "limit the list size",
Value: 25,
},
&cli.TimestampFlag{
Name: "before",
Usage: "only return pipelines before this RFC3339 date",
Layout: time.RFC3339,
},
&cli.TimestampFlag{
Name: "after",
Usage: "only return pipelines after this RFC3339 date",
Layout: time.RFC3339,
},
},
}
@ -64,7 +75,18 @@ func pipelineList(c *cli.Context) error {
return err
}
pipelines, err := client.PipelineList(repoID, woodpecker.PipelineListOptions{})
opt := woodpecker.PipelineListOptions{}
before := c.Timestamp("before")
after := c.Timestamp("after")
if before != nil {
opt.Before = *before
}
if after != nil {
opt.After = *after
}
pipelines, err := client.PipelineList(repoID, opt)
if err != nil {
return err
}

View file

@ -76,4 +76,4 @@ func repoList(c *cli.Context) error {
}
// template for repository list items
var tmplRepoList = "\x1b[33m{{ .FullName }}\x1b[0m (id: {{ .ID }}, forgeRemoteID: {{ .ForgeRemoteID }})"
var tmplRepoList = "\x1b[33m{{ .FullName }}\x1b[0m (id: {{ .ID }}, forgeRemoteID: {{ .ForgeRemoteID }}, isActive: {{ .IsActive }})"