From 2c9c37f8099d63f3eb423b673ede68cadb89fa64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 16:31:34 +0200 Subject: [PATCH] feat: lazysecrets list merges error and expiry into one status field --- cmd/lazysecrets/list.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/lazysecrets/list.go b/cmd/lazysecrets/list.go index 4ca7c04..2342e31 100644 --- a/cmd/lazysecrets/list.go +++ b/cmd/lazysecrets/list.go @@ -29,10 +29,9 @@ import ( // // lazysecrets list | fzf --ansi --delimiter='\t' --with-nth='2..-3' --nth='2..' --accept-nth=-1 // -// Each line is the kind, a mark (★, ◷ and the provider's icon), the name, -// why it couldn't be read (empty unless it failed), whether it expires -// soon or has expired (empty unless so), the account and the link, -// tab-separated. The mark has a field of its own so a search can +// 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 // 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, @@ -46,12 +45,12 @@ 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, error, expiry, account and link, tab-separated; json: an object per line") + format := fs.String("format", "text", "text: kind, mark, name, status, 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)") recent := fs.Bool("recent", withRecent, "put ◷ before names used lately, in mutedColor (text; default ui.recentIcon)") - expiry := fs.Bool("expiry", true, "say which expire within ui.expiryWarningDays (⚠ 12d) or have expired (✗ expired), after the name (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)") showErrors := fs.Bool("errors", true, "list the lists that can't be read, with why (text: ✗ lines; json: \"error\")") if err := fs.Parse(args); err != nil { @@ -86,13 +85,14 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t colored := *color == "always" mark := m.of(e) name := nameOf(e, theme, colored) - why := errorOf(e, theme, colored) - var expires string - if *expiry { - expires = expiryOf(e, theme, expiryWarn, now, colored) + // Why it couldn't be read (vaults, sources), or when it + // expires (secrets, keys, certificates): never both. + status := errorOf(e, theme, colored) + if status == "" && *expiry { + status = expiryOf(e, theme, expiryWarn, now, colored) } // 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\t%s\n", e.Kind, mark, oneLine.Replace(name), oneLine.Replace(why), expires, e.Account, e.Link) + _, 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) return err } case "json":