mirror of
https://github.com/anotherhadi/default-creds-tui.git
synced 2026-10-05 10:58:25 +02:00
@@ -0,0 +1,41 @@
|
||||
package creds
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Entry struct {
|
||||
Manufacturer string
|
||||
Name string
|
||||
Icon string
|
||||
Tags []string
|
||||
Version string
|
||||
User string
|
||||
Pass string
|
||||
Comment string
|
||||
}
|
||||
|
||||
func (e Entry) Title() string { return e.Name }
|
||||
func (e Entry) Description() string { return fmt.Sprintf("%s %s", e.Manufacturer, e.Version) }
|
||||
func (e Entry) FilterValue() string { return e.searchString() }
|
||||
|
||||
func (e Entry) searchString() string {
|
||||
return strings.ToLower(strings.Join([]string{
|
||||
e.Manufacturer, e.Name, e.Comment, strings.Join(e.Tags, " "),
|
||||
}, " "))
|
||||
}
|
||||
|
||||
func (e Entry) matches(tokens []string) bool {
|
||||
s := e.searchString()
|
||||
for _, t := range tokens {
|
||||
if !strings.Contains(s, t) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func queryTokens(query string) []string {
|
||||
return strings.Fields(strings.ToLower(strings.TrimSpace(query)))
|
||||
}
|
||||
Reference in New Issue
Block a user