feat: lazysecrets list marks entries with a note (✎)
This commit is contained in:
2 files changed
+25
-4
No files matched your search
@@ -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)")
|
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)")
|
||||||
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\")")
|
||||||
@@ -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)
|
return fmt.Errorf("--color: %q is not always or never", *color)
|
||||||
}
|
}
|
||||||
now := time.Now()
|
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}
|
color: *color == "always", warn: expiryWarn, now: now}
|
||||||
if *iconsOn {
|
if *iconsOn {
|
||||||
m.icons = icons.NerdFont
|
m.icons = icons.NerdFont
|
||||||
@@ -193,13 +194,13 @@ 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; then the
|
// entry and ◷ for one used lately, as the TUI marks them; ✎ for one with a
|
||||||
// provider's icon. The marks are right-aligned in room for every kind
|
// 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
|
||||||
icons icons.Set
|
icons icons.Set
|
||||||
stars, recent, expiry, color bool
|
stars, recent, notes, expiry, color bool
|
||||||
warn time.Duration // ui.expiryWarningDays
|
warn time.Duration // ui.expiryWarningDays
|
||||||
now time.Time
|
now time.Time
|
||||||
}
|
}
|
||||||
@@ -229,6 +230,9 @@ func (m marks) of(e listing.Entry) string {
|
|||||||
if m.recent {
|
if m.recent {
|
||||||
mark(e.Recent, m.theme.Muted, "◷")
|
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
|
pad := strings.Repeat(" ", room-len(parts)) // each mark and its space
|
||||||
kind := provider.Kind("")
|
kind := provider.Kind("")
|
||||||
for _, k := range []provider.Kind{provider.KindAzure, provider.KindDatabricks, provider.KindRepo} {
|
for _, k := range []provider.Kind{provider.KindAzure, provider.KindDatabricks, provider.KindRepo} {
|
||||||
|
|||||||
@@ -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) {
|
func TestListStatusMark(t *testing.T) {
|
||||||
az := icons.NerdFont.Azure
|
az := icons.NerdFont.Azure
|
||||||
now := time.Date(2026, 10, 14, 12, 0, 0, 0, time.UTC)
|
now := time.Date(2026, 10, 14, 12, 0, 0, 0, time.UTC)
|
||||||
|
|||||||
Reference in new issue
Block a user