/
write.go
62 lines (50 loc) · 2 KB
/
write.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package commands
import (
"github.com/codecare/gokeeper/internal/application"
"github.com/codecare/gokeeper/internal/crypt"
"github.com/codecare/gokeeper/internal/shell"
)
func ExecuteWriteLasteGeneratedPassword(cmd []string) error {
err := shell.SendCharacters(string(application.LastGeneratedPassword), true)
return err
}
func RegisterWriteLasteGeneratedPassword()() {
application.RegisterCommand(
application.CommandDescription{
Name: "Writes last generated password",
Description: "Writes the last generated password to the previous active application",
ShortcutHint: "wg",
Executable: ExecuteWriteLasteGeneratedPassword,
IsApplicable: application.LastGeneratedPasswordExists,
CanHandleShortCut: application.CanHandleShortCutClosure("wg")})
}
func ExecuteWriteSelectedPassword(cmd []string) error {
bytes, err := crypt.DecryptFromContainer(application.ActiveEntry.CryptedPassword)
if err != nil { return err }
err = shell.SendCharacters(string(bytes), true)
return err
}
func RegisterWriteSelectedPassword()() {
application.RegisterCommand(
application.CommandDescription{
Name: "Writes selected password",
Description: "Writes the password of the selected entry to the previous active application",
ShortcutHint: "wp",
Executable: ExecuteWriteSelectedPassword,
IsApplicable: application.OnlyOnActiveEntryExists,
CanHandleShortCut: application.CanHandleShortCutClosure("wp")})
}
func ExecuteWriteSelectedLogin(cmd []string) error {
err := shell.SendCharacters(application.ActiveEntry.Login, true)
return err
}
func RegisterWriteSelectedLogin()() {
application.RegisterCommand(
application.CommandDescription{
Name: "Writes selected login",
Description: "Writes the login of the selected entry to the previous active application",
ShortcutHint: "wl",
Executable: ExecuteWriteSelectedLogin,
IsApplicable: application.OnlyOnActiveEntryExists,
CanHandleShortCut: application.CanHandleShortCutClosure("wl")})
}