This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suggestions.go
42 lines (36 loc) · 1.72 KB
/
suggestions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import "github.com/c-bata/go-prompt"
type completer struct {
NoSuggestion []prompt.Suggest
NoteSelfDestructSuggestion []prompt.Suggest
DestructAfterOpeningSuggestions []prompt.Suggest
}
func buildSuggestions() completer {
return completer{
NoSuggestion: []prompt.Suggest{},
NoteSelfDestructSuggestion: []prompt.Suggest{
{Text: "1h", Description: "In 1 hour your secure note will be deleted"},
{Text: "3h", Description: "In 3 hours your secure note will be deleted"},
{Text: "6h", Description: "In 6 hours your secure note will be deleted"},
{Text: "12h", Description: "In 12 hours your secure note will be deleted"},
{Text: "1d", Description: "In 1 day your secure note will be deleted"},
{Text: "2d", Description: "In 2 days your secure note will be deleted"},
{Text: "3d", Description: "In 3 days your secure note will be deleted"},
{Text: "7d", Description: "In 7 days your secure note will be deleted"},
{Text: "1m", Description: "In 1 month your secure note will be deleted"},
},
DestructAfterOpeningSuggestions: []prompt.Suggest{
{Text: "yes", Description: "your note will be destroyed from our server on the first opening"},
{Text: "no", Description: "we will preserve your note until it expires"},
},
}
}
func (c *completer) noSuggestion(d prompt.Document) []prompt.Suggest {
return c.NoSuggestion
}
func (c *completer) selfDestructSuggestions(d prompt.Document) []prompt.Suggest {
return prompt.FilterContains(c.NoteSelfDestructSuggestion, d.GetWordBeforeCursor(), true)
}
func (c *completer) destructAfterOpeningSuggestions(d prompt.Document) []prompt.Suggest {
return prompt.FilterHasPrefix(c.DestructAfterOpeningSuggestions, d.GetWordBeforeCursor(), true)
}