feat(list): default to no borders, and no header; adds TSV output

This commit is contained in:
Lewis Wynne 2025-11-19 12:37:58 +00:00
parent a4930b781e
commit 885ef5ce4f
2 changed files with 16 additions and 8 deletions

View file

@ -26,11 +26,11 @@ func (e *formatEnum) String() string {
func (e *formatEnum) Set(v string) error {
switch v {
case "table", "csv", "html", "markdown":
case "table", "tsv", "csv", "html", "markdown":
*e = formatEnum(v)
return nil
default:
return fmt.Errorf("must be one of \"table\", \"csv\", \"html\", or \"markdown\"")
return fmt.Errorf("must be one of \"table\", \"tsv\", \"csv\", \"html\", or \"markdown\"")
}
}
@ -44,20 +44,22 @@ var (
noKeys bool = false
noValues bool = false
ttl bool = false
noHeader bool = false
header bool = false
format formatEnum = "table"
)
func enrichFlags() (ListArgs, error) {
var renderFunc func(tw table.Writer)
switch format.String() {
case "tsv":
renderFunc = func(tw table.Writer) { tw.RenderTSV() }
case "csv":
renderFunc = func(tw table.Writer) { tw.RenderCSV() }
case "html":
renderFunc = func(tw table.Writer) { tw.RenderHTML() }
case "markdown":
renderFunc = func(tw table.Writer) { tw.RenderMarkdown() }
default:
case "table":
renderFunc = func(tw table.Writer) { tw.Render() }
}
@ -66,7 +68,7 @@ func enrichFlags() (ListArgs, error) {
}
return ListArgs{
header: !noHeader,
header: header,
key: !noKeys,
value: !noValues,
ttl: ttl,