woodpecker
woodpecker copied to clipboard
Add cli output handlers
❯ ./dist/woodpecker-cli pipeline ls --help
NAME:
woodpecker-cli pipeline ls - show pipeline history
USAGE:
woodpecker-cli pipeline ls [command options] <repo-id|repo-full-name>
OPTIONS:
--output value output format (default: "table")
--no-header don't print headers (default: false)
--branch value branch filter
--event value event filter
--status value status filter
--limit value limit the list size (default: 25)
--help, -h show help
########
# use default table output
❯ ./dist/woodpecker-cli pipeline ls --limit 2 2
NUMBER STATUS EVENT BRANCH COMMIT AUTHOR
43 error manual main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
42 success push main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
########
# auto-fallback to table output
❯ ./dist/woodpecker-cli pipeline ls --limit 2 --output foo 2
NUMBER STATUS EVENT BRANCH COMMIT AUTHOR
43 error manual main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
42 success push main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
########
# use explicit table output
❯ ./dist/woodpecker-cli pipeline ls --limit 2 --output table 2
NUMBER STATUS EVENT BRANCH COMMIT AUTHOR
43 error manual main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
42 success push main 473761d8b26b20f7c206408563d54cf998410329 woodpecker
########
# customize table output
❯ ./dist/woodpecker-cli pipeline ls --limit 2 --output table=number,status,event 2
NUMBER STATUS EVENT
43 error manual
42 success push
########
# customize table output and disable header
❯ ./dist/woodpecker-cli pipeline ls --limit 2 --output table=number,status,event --no-header 2
43 error manual
42 success push
########
# go crazy and use a template layout
❯ ./dist/woodpecker-cli pipeline ls --limit 2 --output go-template='{{range .}}{{printf "\x1b[33mPipeline #%d\x1b[0m\nStatus: %s\nEvent:%s\nCommit:%s\n\n" .Number .Status .Event .Commit}}{{end}}' 2
Pipeline #43
Status: error
Event:manual
Commit:473761d8b26b20f7c206408563d54cf998410329
Pipeline #42
Status: success
Event:push
Commit:473761d8b26b20f7c206408563d54cf998410329
@woodpecker-ci/maintainers I would like to get some feedback in this early state. Please let me know what you think about this implementation.
I added mocks for the woodpecker-go
client to add some cli tests. However, injecting mock clients into urfave/cli
commands is a bit crappy, or I'm too stupid to find a better solution. If you have a better idea, please let me know, happy to change it.
Deployment of preview was successful: https://woodpecker-ci-woodpecker-pr-3660.surge.sh