| 1 |
package account |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
|
| 6 |
"git.sr.ht/~rjarry/aerc/app" |
| 7 |
"git.sr.ht/~rjarry/aerc/commands" |
| 8 |
) |
| 9 |
|
| 10 |
type SelectMessage struct { |
| 11 |
Index int `opt:"n" minus:"true"` |
| 12 |
} |
| 13 |
|
| 14 |
func init() { |
| 15 |
commands.Register(SelectMessage{}) |
| 16 |
} |
| 17 |
|
| 18 |
func (SelectMessage) Description() string { |
| 19 |
return "Select the <N>th message in the message list." |
| 20 |
} |
| 21 |
|
| 22 |
func (SelectMessage) Context() commands.CommandContext { |
| 23 |
return commands.MESSAGE_LIST |
| 24 |
} |
| 25 |
|
| 26 |
func (SelectMessage) Aliases() []string { |
| 27 |
return []string{"select", "select-message"} |
| 28 |
} |
| 29 |
|
| 30 |
func (s SelectMessage) Execute(args []string) error { |
| 31 |
acct := app.SelectedAccount() |
| 32 |
if acct == nil { |
| 33 |
return errors.New("No account selected") |
| 34 |
} |
| 35 |
if acct.Messages().Empty() { |
| 36 |
return nil |
| 37 |
} |
| 38 |
acct.Messages().Select(s.Index) |
| 39 |
return nil |
| 40 |
} |