feat: underlined header texts, and one-space right pad

This commit is contained in:
Lewis Wynne 2026-02-11 14:17:48 +00:00
parent 24853bfce8
commit 1f4732823d
3 changed files with 34 additions and 30 deletions

View file

@ -192,7 +192,7 @@ pda rm kitty -i
`pda ls` to see what you've got stored. `pda ls` to see what you've got stored.
```bash ```bash
pda ls pda ls
# KEY VALUE TTL # Key Value TTL
# name Alice no expiry # name Alice no expiry
# dogs four legged mammals no expiry # dogs four legged mammals no expiry
@ -210,11 +210,11 @@ pda ls --format csv
Long values are truncated to fit the terminal. Use `--full`/`-f` to show the complete value. Long values are truncated to fit the terminal. Use `--full`/`-f` to show the complete value.
```bash ```bash
pda ls pda ls
# KEY VALUE TTL # Key Value TTL
# note this is a very long (..30 more chars) no expiry # note this is a very long (..30 more chars) no expiry
pda ls --full pda ls --full
# KEY VALUE TTL # Key Value TTL
# note this is a very long value that keeps on going and going no expiry # note this is a very long value that keeps on going and going no expiry
``` ```
@ -554,7 +554,7 @@ pda set session2 "xyz" --ttl 54m10s
`list` shows expiration in the TTL column by default. `list` shows expiration in the TTL column by default.
```bash ```bash
pda ls pda ls
# KEY VALUE TTL # Key Value TTL
# session 123 in 59m30s # session 123 in 59m30s
# session2 xyz in 51m40s # session2 xyz in 51m40s
``` ```
@ -644,7 +644,7 @@ pda set api-key "oops"
If the identity file is missing, encrypted values are inaccessible but not lost. Keys are still visible, and the ciphertext is preserved through reads and writes. If the identity file is missing, encrypted values are inaccessible but not lost. Keys are still visible, and the ciphertext is preserved through reads and writes.
```bash ```bash
pda ls pda ls
# KEY VALUE TTL # Key Value TTL
# api-key locked (identity file missing) no expiry # api-key locked (identity file missing) no expiry
pda get api-key pda get api-key

View file

@ -194,10 +194,8 @@ func list(cmd *cobra.Command, args []string) error {
tty := stdoutIsTerminal() && listFormat.String() == "table" tty := stdoutIsTerminal() && listFormat.String() == "table"
if !listNoHeader { if !listNoHeader {
tw.AppendHeader(headerRow(columns)) tw.AppendHeader(headerRow(columns, tty))
if tty { tw.Style().Format.Header = text.FormatDefault
tw.Style().Color.Header = text.Colors{text.Bold}
}
} }
lay := computeLayout(columns, output, filtered) lay := computeLayout(columns, output, filtered)
@ -313,16 +311,22 @@ func summariseValue(s string, maxWidth int, tty bool) string {
return text.Trim(first, maxWidth) return text.Trim(first, maxWidth)
} }
func headerRow(columns []columnKind) table.Row { func headerRow(columns []columnKind, tty bool) table.Row {
h := func(s string) interface{} {
if tty {
return text.Underline.Sprint(s)
}
return s
}
row := make(table.Row, 0, len(columns)) row := make(table.Row, 0, len(columns))
for _, col := range columns { for _, col := range columns {
switch col { switch col {
case columnKey: case columnKey:
row = append(row, "Key") row = append(row, h("Key"))
case columnValue: case columnValue:
row = append(row, "Value") row = append(row, h("Value"))
case columnTTL: case columnTTL:
row = append(row, "TTL") row = append(row, h("TTL"))
} }
} }
return row return row

View file

@ -1,7 +1,7 @@
$ pda set foo 1 $ pda set foo 1
$ pda set bar 2 $ pda set bar 2
$ pda ls $ pda ls
KEY VALUE TTL Key Value TTL
a echo hello (..1 more chars) no expiry a echo hello (..1 more chars) no expiry
a1 1 no expiry a1 1 no expiry
a2 2 no expiry a2 2 no expiry