feat: lazysecrets list prints notes, and --demo has a couple
This commit is contained in:
4 files changed
+31
-18
No files matched your search
@@ -31,7 +31,8 @@ import (
|
||||
//
|
||||
// Each line is the kind, a mark (✗ or ⚠, ★, ◷ and the provider's icon),
|
||||
// the name, a status (why it couldn't be read, or that it has expired or
|
||||
// expires soon; else empty), the account and the link, tab-separated. The mark has a field of its own so a search can
|
||||
// expires soon; else empty), its note (muted, or empty), the account and
|
||||
// the link, tab-separated. The mark has a field of its own so a search can
|
||||
// leave it out (fzf --nth), and ^prod finds names starting with prod. The
|
||||
// name is coloured from the theme,
|
||||
// with the provider's icon (as in the TUI: --icons, LAZYSECRETS_ICONS,
|
||||
@@ -45,7 +46,7 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t
|
||||
fs := flag.NewFlagSet("list", flag.ContinueOnError)
|
||||
cached := fs.Bool("cached", false, "only what's cached, and repos: load nothing from Azure or Databricks")
|
||||
maxAge := fs.Duration("max-age", 2*time.Minute, "load cached lists older than this again")
|
||||
format := fs.String("format", "text", "text: kind, mark, name, status, account and link, tab-separated; json: an object per line")
|
||||
format := fs.String("format", "text", "text: kind, mark, name, status, note, account and link, tab-separated; json: an object per line")
|
||||
color := fs.String("color", "always", "colour the names (text): always or never; fzf needs --ansi")
|
||||
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)")
|
||||
@@ -91,8 +92,10 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t
|
||||
if status == "" && *expiry {
|
||||
status = expiryOf(e, theme, expiryWarn, now, colored)
|
||||
}
|
||||
note := renderer(colored)(theme.Muted, e.Note)
|
||||
// A tab or line break in a name would break the line up.
|
||||
_, err := fmt.Fprintf(out, "%s\t%s\t%s\t%s\t%s\t%s\n", e.Kind, mark, oneLine.Replace(name), oneLine.Replace(status), e.Account, e.Link)
|
||||
_, err := fmt.Fprintf(out, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", e.Kind, mark, oneLine.Replace(name), oneLine.Replace(status),
|
||||
oneLine.Replace(note), e.Account, e.Link)
|
||||
return err
|
||||
}
|
||||
case "json":
|
||||
@@ -124,9 +127,9 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t
|
||||
}
|
||||
f = listing.Run(context.Background(), listing.Options{
|
||||
Providers: providers, Cache: f, MaxAge: *maxAge, Cached: *cached, Kinds: only, Timeout: timeout,
|
||||
Mark: func(link, account string) (bool, time.Time, int) {
|
||||
Mark: func(link, account string) (bool, time.Time, int, string) {
|
||||
n := st.Node(link)
|
||||
return n.StarredFor(account), n.LastUsed, n.Uses
|
||||
return n.StarredFor(account), n.LastUsed, n.Uses, n.Note
|
||||
},
|
||||
}, emit)
|
||||
if cachePath != "" && !*cached {
|
||||
|
||||
Reference in new issue
Block a user