expose pipeline list options to cli

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

View file

@ -15,6 +15,8 @@
package pipeline
import (
"time"
"github.com/urfave/cli/v2"
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
@ -46,6 +48,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,
},
}...),
}
@ -70,7 +82,18 @@ func pipelineList(c *cli.Context, client woodpecker.Client) ([]woodpecker.Pipeli
return resources, 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 resources, 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 }})"