From 5946f855bd02d5f0d2e193f63439533cee500275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 16:37:38 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20lazysecrets=20list=20marks=20entries=20?= =?UTF-8?q?with=20a=20note=20(=E2=9C=8E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/lazysecrets/list.go | 20 ++++++++++++-------- cmd/lazysecrets/list_test.go | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/cmd/lazysecrets/list.go b/cmd/lazysecrets/list.go index 3a3531a..8cef3d9 100644 --- a/cmd/lazysecrets/list.go +++ b/cmd/lazysecrets/list.go @@ -51,6 +51,7 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t iconsOn := fs.Bool("icons", withIcons, "put the provider's Nerd Font icon before names (text)") stars := fs.Bool("stars", true, "put ★ before starred names, in the theme's favouriteColor (text)") recent := fs.Bool("recent", withRecent, "put ◷ before names used lately, in mutedColor (text; default ui.recentIcon)") + notes := fs.Bool("notes", true, "put ✎ before names with a note, in mutedColor (text; the note is printed either way)") expiry := fs.Bool("expiry", true, "mark and say which have expired (✗ expired) or expire within ui.expiryWarningDays (⚠ expires in 12d) (text)") kinds := fs.String("kind", "", "only these kinds, comma-separated: "+strings.Join(listing.Kinds, ", ")+" (vault: also scopes and repo files)") showErrors := fs.Bool("errors", true, "list the lists that can't be read, with why (text: ✗ lines; json: \"error\")") @@ -74,7 +75,7 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t return fmt.Errorf("--color: %q is not always or never", *color) } now := time.Now() - m := marks{theme: theme, icons: icons.None, stars: *stars, recent: *recent, expiry: *expiry, + m := marks{theme: theme, icons: icons.None, stars: *stars, recent: *recent, notes: *notes, expiry: *expiry, color: *color == "always", warn: expiryWarn, now: now} if *iconsOn { m.icons = icons.NerdFont @@ -193,15 +194,15 @@ func nameOf(e listing.Entry, theme styles.Styles, color bool) string { // marks says what goes before the name, in a field of its own so a // search leaves it out: ✗ in red when something's wrong (it couldn't be // read, or has expired) or ⚠ when it expires within warn; ★ for a starred -// entry and ◷ for one used lately, as the TUI marks them; then the -// provider's icon. The marks are right-aligned in room for every kind +// entry and ◷ for one used lately, as the TUI marks them; ✎ for one with a +// note; then the provider's icon. The marks are right-aligned in room for every kind // turned on, so they sit by the icon and names line up. type marks struct { - theme styles.Styles - icons icons.Set - stars, recent, expiry, color bool - warn time.Duration // ui.expiryWarningDays - now time.Time + theme styles.Styles + icons icons.Set + stars, recent, notes, expiry, color bool + warn time.Duration // ui.expiryWarningDays + now time.Time } func (m marks) of(e listing.Entry) string { @@ -229,6 +230,9 @@ func (m marks) of(e listing.Entry) string { if m.recent { mark(e.Recent, m.theme.Muted, "◷") } + if m.notes { + mark(e.Note != "", m.theme.Muted, "✎") + } pad := strings.Repeat(" ", room-len(parts)) // each mark and its space kind := provider.Kind("") for _, k := range []provider.Kind{provider.KindAzure, provider.KindDatabricks, provider.KindRepo} { diff --git a/cmd/lazysecrets/list_test.go b/cmd/lazysecrets/list_test.go index 1dd358c..7056460 100644 --- a/cmd/lazysecrets/list_test.go +++ b/cmd/lazysecrets/list_test.go @@ -87,6 +87,23 @@ func TestListExpiry(t *testing.T) { } } +func TestListNoteMark(t *testing.T) { + az := icons.NerdFont.Azure + m := marks{icons: icons.NerdFont, stars: true, notes: true} + for _, c := range []struct { + e listing.Entry + want string + }{ + {listing.Entry{Provider: "azure", Note: "rotate in May"}, " ✎ " + az}, + {listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ ✎ " + az}, + {listing.Entry{Provider: "azure"}, " " + az}, + } { + if got := m.of(c.e); got != c.want { + t.Errorf("%+v: %q, want %q", c.e, got, c.want) + } + } +} + func TestListStatusMark(t *testing.T) { az := icons.NerdFont.Azure now := time.Date(2026, 10, 14, 12, 0, 0, 0, time.UTC)