Debian Codegraph @

commands/compose/sign.go

raw
1 package compose
2
3 import (
4 "time"
5
6 "git.sr.ht/~rjarry/aerc/app"
7 "git.sr.ht/~rjarry/aerc/commands"
8 )
9
10 type Sign struct{}
11
12 func init() {
13 commands.Register(Sign{})
14 }
15
16 func (Sign) Description() string {
17 return "Sign the message using the account default key."
18 }
19
20 func (Sign) Context() commands.CommandContext {
21 return commands.COMPOSE_EDIT | commands.COMPOSE_REVIEW
22 }
23
24 func (Sign) Aliases() []string {
25 return []string{"sign"}
26 }
27
28 func (Sign) Execute(args []string) error {
29 composer, _ := app.SelectedTabContent().(*app.Composer)
30
31 err := composer.SetSign(!composer.Sign())
32 if err != nil {
33 return err
34 }
35
36 var statusline string
37
38 if composer.Sign() {
39 statusline = "Message will be signed."
40 } else {
41 statusline = "Message will not be signed."
42 }
43
44 app.PushStatus(statusline, 10*time.Second)
45
46 return nil
47 }