feat: lazysecrets list's note mark is a Nerd Font note, ✎ without icons
This commit is contained in:
3 files changed
+14
-6
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"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)")
|
||||
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)")
|
||||
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)")
|
||||
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\")")
|
||||
@@ -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
|
||||
// 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; ✎ for one with a
|
||||
// note; 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; a note icon
|
||||
// (✎ 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.
|
||||
type marks struct {
|
||||
theme styles.Styles
|
||||
@@ -231,7 +233,7 @@ func (m marks) of(e listing.Entry) string {
|
||||
mark(e.Recent, m.theme.Muted, "◷")
|
||||
}
|
||||
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
|
||||
kind := provider.Kind("")
|
||||
|
||||
@@ -94,14 +94,18 @@ func TestListNoteMark(t *testing.T) {
|
||||
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", Note: "rotate in May"}, " " + icons.NerdFont.Note + " " + az},
|
||||
{listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ " + icons.NerdFont.Note + " " + 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)
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
||||
Reference in new issue
Block a user