feat: lazysecrets list prints the account, and open and get take it (--account)
This commit is contained in:
9 files changed
+118
-43
No files matched your search
@@ -218,6 +218,9 @@ func (m *Model) openSource(r ref.Ref) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if row, ok := preferredRow(r, choices); ok {
|
||||
choices = []choice{{sourceRow: row}}
|
||||
}
|
||||
switch len(choices) {
|
||||
case 0:
|
||||
m.flash = flash{text: "open: " + describeRef(r) + " isn't in your sources", isErr: true}
|
||||
@@ -410,6 +413,10 @@ func (m *Model) handleResolved(msg resolvedMsg) {
|
||||
for _, row := range append([]string{msg.sourceRow}, msg.others...) {
|
||||
choices = append(choices, choice{label: "Open with " + m.sourceLabel(row), sourceRow: row})
|
||||
}
|
||||
if row, ok := preferredRow(msg.ref, choices); ok {
|
||||
m.startLinkNav(msg.ref, msg.act, row)
|
||||
return
|
||||
}
|
||||
m.chooseSource("Several accounts can see "+msg.ref.ContainerName(), msg.ref, msg.act, choices, true)
|
||||
case msg.linked != nil:
|
||||
m.addLinked(*msg.linked)
|
||||
@@ -419,6 +426,17 @@ func (m *Model) handleResolved(msg resolvedMsg) {
|
||||
}
|
||||
}
|
||||
|
||||
// preferredRow is the choice under the account the reference asks for
|
||||
// (ref.Ref.Account), if it's one of them.
|
||||
func preferredRow(r ref.Ref, choices []choice) (string, bool) {
|
||||
for _, c := range choices {
|
||||
if r.Account != "" && providerOf(c.sourceRow) == r.Account {
|
||||
return c.sourceRow, true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// startLinkNav opens a link: like startNav, ending on its object's
|
||||
// details.
|
||||
func (m *Model) startLinkNav(r ref.Ref, act linkAction, sourceRow string) {
|
||||
|
||||
Reference in new issue
Block a user