feat: the value's keys on the line below it: reveal and copy
CI / Checks (pull_request) Successful in 24s
PR title / Conventional title (pull_request) Successful in 2s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kebandClaude Opus 5.5 committed 2026-10-11 10:34:12 +02:00
1 parent f6c4f5f6f6
commit c04ad389ee
4 files changed
+34 -30

No files matched your search

+24 -20
View File
@@ -31,7 +31,7 @@ type Detail struct {
Icons icons.Set
// RevealKey and VersionsKey are the keys hints mention ("space to
// reveal"); a hint is left out when its key is "" (unbound).
RevealKey, VersionsKey string
RevealKey, VersionsKey, CopyKey string
secret *provider.Object
container *provider.Container
@@ -70,7 +70,7 @@ func (d *Detail) ShowContainer(c provider.Container) {
// Clear drops the selection and any fetched value.
func (d *Detail) Clear() {
*d = Detail{Now: d.Now, Icons: d.Icons, RevealKey: d.RevealKey, VersionsKey: d.VersionsKey, w: d.w, h: d.h} // drops the note too
*d = Detail{Now: d.Now, Icons: d.Icons, RevealKey: d.RevealKey, VersionsKey: d.VersionsKey, CopyKey: d.CopyKey, w: d.w, h: d.h} // drops the note too
}
// SetMessage sets what's shown instead of the hint when nothing is
@@ -284,24 +284,35 @@ func (d Detail) lines(st styles.Styles) []string {
}
// Secrets are masked; keys and certificates only expose public material.
keyHint := func(k, what string) string {
if k == "" {
return ""
// What the keys do with the value, on the line under it.
hints := func(reveal string, more ...string) string {
var h []string
if d.RevealKey != "" {
h = append(h, d.RevealKey+" to "+reveal)
}
return "(" + k + " to " + what + ")"
if d.CopyKey != "" {
h = append(h, d.CopyKey+" to copy")
}
return muted(strings.Join(append(h, more...), " · "))
}
label, hidden := "value", st.Masked.Render("••••••••")+muted(" "+keyHint(d.RevealKey, "reveal"))
label, hidden, reveal := "value", st.Masked.Render("••••••••"), "reveal"
switch s.Type {
case provider.TypeKey:
label, hidden = "public", muted(keyHint(d.RevealKey, "show public key"))
label, hidden, reveal = "public", "", "show the public key"
case provider.TypeCertificate:
label, hidden = "cert", muted(keyHint(d.RevealKey, "show certificate"))
label, hidden, reveal = "cert", "", "show the certificate"
}
indent := strings.Repeat(" ", 12)
out = append(out, "")
switch d.state {
case ValueHidden:
field(label, hidden)
if hidden != "" {
field(label, hidden)
out = append(out, indent+hints(reveal))
} else {
field(label, hints(reveal))
}
case ValueLoading:
field(label, spinnerPlaceholder+" fetching…")
case ValueFailed:
@@ -322,18 +333,11 @@ func (d Detail) lines(st styles.Styles) []string {
}
}
case ValueShown:
var hints []string
if d.RevealKey != "" {
hints = append(hints, d.RevealKey+" to hide")
}
var more []string
if d.hidesIn != "" {
hints = append(hints, "hides in "+d.hidesIn)
more = append(more, "hides in "+d.hidesIn)
}
line := " " + st.Label.Render(label)
if len(hints) > 0 {
line += muted(" (" + strings.Join(hints, " · ") + ")")
}
out = append(out, line)
out = append(out, " "+st.Label.Render(fmt.Sprintf("%-10s", label))+" "+hints("hide", more...))
for _, line := range strings.Split(d.value.Reveal(), "\n") {
for _, w := range strings.Split(ansi.Hardwrap(line, inner, true), "\n") {
out = append(out, " "+st.Value.Render(w))