feat: lazysecrets list's note mark is a Nerd Font note, ✎ without icons

This commit is contained in:
keb committed 2026-10-14 21:24:01 +02:00
1 parent 5946f855bd
commit 1c5a6a5087
3 files changed
+14 -6

No files matched your search

+6 -4
View File
@@ -1,6 +1,7 @@
package main package main
import ( import (
"cmp"
"context" "context"
"encoding/json" "encoding/json"
"errors" "errors"
@@ -51,7 +52,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)") 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)") 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)") 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)") notes := fs.Bool("notes", true, "put a note icon (✎ without --icons) 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)") 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)") 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\")") showErrors := fs.Bool("errors", true, "list the lists that can't be read, with why (text: ✗ lines; json: \"error\")")
@@ -194,8 +195,9 @@ 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 // 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 // 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 // read, or has expired) or ⚠ when it expires within warn; ★ for a starred
// entry and ◷ for one used lately, as the TUI marks them; ✎ for one with a // entry and ◷ for one used lately, as the TUI marks them; a note icon
// note; then the provider's icon. The marks are right-aligned in room for every kind // (✎ without Nerd Font icons) 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. // turned on, so they sit by the icon and names line up.
type marks struct { type marks struct {
theme styles.Styles theme styles.Styles
@@ -231,7 +233,7 @@ func (m marks) of(e listing.Entry) string {
mark(e.Recent, m.theme.Muted, "◷") mark(e.Recent, m.theme.Muted, "◷")
} }
if m.notes { if m.notes {
mark(e.Note != "", m.theme.Muted, "✎") mark(e.Note != "", m.theme.Muted, cmp.Or(m.icons.Note, "✎"))
} }
pad := strings.Repeat(" ", room-len(parts)) // each mark and its space pad := strings.Repeat(" ", room-len(parts)) // each mark and its space
kind := provider.Kind("") kind := provider.Kind("")
+6 -2
View File
@@ -94,14 +94,18 @@ func TestListNoteMark(t *testing.T) {
e listing.Entry e listing.Entry
want string want string
}{ }{
{listing.Entry{Provider: "azure", Note: "rotate in May"}, " ✎ " + az}, {listing.Entry{Provider: "azure", Note: "rotate in May"}, " " + icons.NerdFont.Note + " " + az},
{listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ ✎ " + az}, {listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ " + icons.NerdFont.Note + " " + az},
{listing.Entry{Provider: "azure"}, " " + az}, {listing.Entry{Provider: "azure"}, " " + az},
} { } {
if got := m.of(c.e); got != c.want { if got := m.of(c.e); got != c.want {
t.Errorf("%+v: %q, want %q", c.e, got, c.want) t.Errorf("%+v: %q, want %q", c.e, got, c.want)
} }
} }
m.icons = icons.None // without Nerd Font icons
if got := m.of(listing.Entry{Provider: "azure", Note: "x"}); got != " ✎" {
t.Errorf("no icons: %q", got)
}
} }
func TestListStatusMark(t *testing.T) { func TestListStatusMark(t *testing.T) {
+2
View File
@@ -11,6 +11,7 @@ type Set struct {
Repo string Repo string
Encrypted string // an encrypted file (SOPS) Encrypted string // an encrypted file (SOPS)
PlainFile string // a plain text secrets file (.env) PlainFile string // a plain text secrets file (.env)
Note string // has a note (lazysecrets list)
} }
// None renders no icons. // None renders no icons.
@@ -24,6 +25,7 @@ var NerdFont = Set{
Repo: "\U000F02A2", // md-git Repo: "\U000F02A2", // md-git
Encrypted: "\U000F033E", // md-lock Encrypted: "\U000F033E", // md-lock
PlainFile: "\U000F0214", // md-file PlainFile: "\U000F0214", // md-file
Note: "\U000F09ED",
} }
// Prefix returns the icon for kind followed by a space, or "" if the set has // Prefix returns the icon for kind followed by a space, or "" if the set has