feat: lazysecrets list prints everything lazysecrets can find, for fzf and editor pickers #70
No files matched your search
@@ -169,9 +169,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
|
||||
// search leaves it out: ★ for a starred entry, ◷ for one used lately,
|
||||
// ⚠ for one expiring within warn and ✗ for an expired one (as the TUI
|
||||
// marks them; a space as wide where it isn't, so names line up), then the
|
||||
// provider's icon.
|
||||
// ⚠ for one expiring within warn and ✗ for an expired one, as the TUI
|
||||
// marks them, then the provider's icon. Only the marks an entry has take
|
||||
// space.
|
||||
type marks struct {
|
||||
theme styles.Styles
|
||||
icons icons.Set
|
||||
@@ -184,10 +184,9 @@ func (m marks) of(e listing.Entry) string {
|
||||
render := renderer(m.color)
|
||||
var parts []string
|
||||
mark := func(on bool, st lipgloss.Style, s string) {
|
||||
if !on {
|
||||
s = " "
|
||||
if on {
|
||||
parts = append(parts, render(st, s))
|
||||
}
|
||||
parts = append(parts, render(st, s))
|
||||
}
|
||||
if m.stars {
|
||||
mark(e.Starred, m.theme.Favourite, "★")
|
||||
|
||||
@@ -34,7 +34,7 @@ func TestListMarks(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{plain, listing.Entry{Provider: "azure", Starred: true}, "★ " + az},
|
||||
{plain, listing.Entry{Provider: "azure"}, " " + az}, // as wide as ★
|
||||
{plain, listing.Entry{Provider: "azure"}, az}, // no space for a star it hasn't
|
||||
{marks{icons: icons.NerdFont}, listing.Entry{Provider: "azure", Starred: true}, az},
|
||||
{noIcons, listing.Entry{Provider: "azure", Starred: true}, "★"},
|
||||
{marks{}, listing.Entry{Provider: "azure", Starred: true}, ""},
|
||||
@@ -54,11 +54,11 @@ func TestListRecentAndExpiryMarks(t *testing.T) {
|
||||
e listing.Entry
|
||||
want string
|
||||
}{
|
||||
{listing.Entry{Provider: "azure", Starred: true, Recent: true}, "★ ◷ " + az},
|
||||
{listing.Entry{Provider: "azure", Recent: true}, " ◷ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(-time.Hour)}, " ✗ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(10 * 24 * time.Hour)}, " ⚠ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(60 * 24 * time.Hour)}, " " + az},
|
||||
{listing.Entry{Provider: "azure", Starred: true, Recent: true}, "★ ◷ " + az},
|
||||
{listing.Entry{Provider: "azure", Recent: true}, "◷ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(-time.Hour)}, "✗ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(10 * 24 * time.Hour)}, "⚠ " + az},
|
||||
{listing.Entry{Provider: "azure", Expires: now.Add(60 * 24 * time.Hour)}, az},
|
||||
} {
|
||||
if got := m.of(c.e); got != c.want {
|
||||
t.Errorf("%+v: %q, want %q", c.e, got, c.want)
|
||||
|
||||
Reference in new issue
Block a user