feat(console): tabled outputs now optionally return without decorations
All checks were successful
ci/woodpecker/pr/docs Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/docker Pipeline was successful
ci/woodpecker/pr/man Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful

This commit is contained in:
Jef Roosens 2022-09-11 21:50:29 +02:00
parent cf67b46df0
commit 8a08788935
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
4 changed files with 34 additions and 10 deletions

View file

@ -60,7 +60,9 @@ pub fn cmd() cli.Command {
filter.repo = repo
}
list(conf, filter)?
raw := cmd.flags.get_bool('raw')?
list(conf, filter, raw)?
}
},
cli.Command{
@ -193,12 +195,16 @@ pub fn cmd() cli.Command {
// ID. If multiple or none are found, an error is raised.
// list prints out a list of all repositories.
fn list(conf Config, filter TargetFilter) ? {
fn list(conf Config, filter TargetFilter, raw bool) ? {
c := client.new(conf.address, conf.api_key)
repos := c.get_targets(filter)?
data := repos.map([it.id.str(), it.kind, it.url, it.repo])
println(console.pretty_table(['id', 'kind', 'url', 'repo'], data)?)
if raw {
println(console.tabbed_table(data))
} else {
println(console.pretty_table(['id', 'kind', 'url', 'repo'], data)?)
}
}
// add adds a new repository to the server's list.