feat: add remove entry
This commit is contained in:
parent
d055cc34ec
commit
20b4334759
1 changed files with 24 additions and 0 deletions
24
gpm/cli.go
24
gpm/cli.go
|
@ -168,6 +168,26 @@ func (c *Cli) UnlockWallet(wallet string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (c *Cli) DeleteEntry(entry Entry) bool {
|
||||
if !c.ChoiceBox("Do you want delete this entry ?", false) {
|
||||
return false
|
||||
}
|
||||
|
||||
err := c.Wallet.DeleteEntry(entry.ID)
|
||||
if err != nil {
|
||||
c.NotificationBox(fmt.Sprintf("%s", err), true)
|
||||
return false
|
||||
}
|
||||
|
||||
err = c.Wallet.Save()
|
||||
if err != nil {
|
||||
c.NotificationBox(fmt.Sprintf("%s", err), true)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Cli) UpdateEntry(entry Entry) bool {
|
||||
entry.Name = c.InputBox("Name", entry.Name, false)
|
||||
entry.Group = c.InputBox("Group", entry.Group, false)
|
||||
|
@ -278,6 +298,10 @@ func (c *Cli) ListEntries() {
|
|||
if len(entries) > 0 && index >= 0 && index < len(entries) {
|
||||
refresh = c.UpdateEntry(entries[index])
|
||||
}
|
||||
case "d":
|
||||
if len(entries) > 0 && index >= 0 && index < len(entries) {
|
||||
refresh = c.DeleteEntry(entries[index])
|
||||
}
|
||||
case "/":
|
||||
pattern = c.InputBox("Search", pattern, false)
|
||||
refresh = true
|
||||
|
|
Loading…
Reference in a new issue