feat: lazysecrets list prints everything lazysecrets can find, for fzf and editor pickers #70

Merged
keb merged 45 commits from feat/list into main 2026-10-14 21:30:44 +02:00
3 changed files with 9 additions and 13 deletions
Showing only changes of commit 3734989b15 - Show all commits

No files matched your search

+4 -8
View File
@@ -34,7 +34,7 @@ import (
//
// What's cached prints at once; what's missing or older than --max-age
// follows as it loads. A list that can't be read is a line too, as it
// fails: ✗, the vault or source, and why, in the theme's error colour.
// fails: the vault or source, then ✗ and why in the theme's error colour.
// They're in the output rather than on stderr, which would draw over fzf.
func listCmd(providers []provider.Provider, cachePath string, timeout func(provider.Kind) time.Duration, theme styles.Styles, withIcons bool, args []string, out io.Writer) error {
fs := flag.NewFlagSet("list", flag.ContinueOnError)
@@ -126,7 +126,7 @@ var oneLine = strings.NewReplacer("\t", " ", "\r\n", " ", "\n", " ", "\r", " ")
// nameOf is an entry's name for the text format: the provider's icon,
// the path with the item's own name standing out, and the account. A
// list that couldn't be read has ✗ for the icon, and why after it.
// list that couldn't be read has ✗ and why after it.
func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool) string {
render := func(st lipgloss.Style, s string) string {
if !color || s == "" {
@@ -141,10 +141,6 @@ func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool)
}
}
icon := iconSet.Prefix(kind)
iconStyle := theme.Kind(kind)
if e.Error != "" {
icon, iconStyle = "✗ ", theme.Error
}
var name string
if n := len(e.Path); n > 0 {
if n > 1 {
@@ -156,7 +152,7 @@ func nameOf(e listing.Entry, theme styles.Styles, iconSet icons.Set, color bool)
name += render(theme.Muted, " · "+e.Account)
}
if e.Error != "" {
name += " " + render(theme.Error, e.Error)
name += " " + render(theme.Error, "✗ "+e.Error)
}
return render(iconStyle, strings.TrimSuffix(icon, " ")) + strings.Repeat(" ", min(len(icon), 1)) + name
return render(theme.Kind(kind), strings.TrimSuffix(icon, " ")) + strings.Repeat(" ", min(len(icon), 1)) + name
}
+2 -2
View File
@@ -26,10 +26,10 @@ func TestListNames(t *testing.T) {
func TestListErrorNames(t *testing.T) {
e := listing.Entry{Provider: "azure", Path: []string{"platform-prod", "kv-restricted"}, Error: "403 Forbidden"}
if got := nameOf(e, styles.Default(), icons.NerdFont, false); got != "✗ platform-prod / kv-restricted 403 Forbidden" {
if got := nameOf(e, styles.Default(), icons.NerdFont, false); got != icons.NerdFont.Azure+" platform-prod / kv-restricted ✗ 403 Forbidden" {
t.Errorf("plain: %q", got)
}
red := styles.Default().Error.Render("403 Forbidden")
red := styles.Default().Error.Render("✗ 403 Forbidden")
if got := nameOf(e, styles.Default(), icons.NerdFont, true); !strings.HasSuffix(got, red) {
t.Errorf("why isn't in the error colour: %q", got)
}
+3 -3
View File
@@ -162,9 +162,9 @@ only other kinds need aren't loaded: `--kind source,vault` asks for no
secrets. Keys and certificates load only when asked for this way; else,
like Go to, they're listed as far as you opened them in lazysecrets.
A vault or source it can't read is a line too, as it fails: `✗`, its
name and why, in red (`errorColor`), with its link, so opening it shows
more. They're in the list, not on stderr, which would draw over fzf.
A vault or source it can't read is a line too, as it fails: its name,
then `✗` and why in red (`errorColor`), with its link, so opening it
shows more. They're in the list, not on stderr, which would draw over fzf.
`--errors=false` leaves them out.
The name is coloured from your [theme](config.md#theme), with the