File: commands.go

package info (click to toggle)
golang-github-emersion-go-imap-uidplus 0.0~git20200503.e75854c-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 80 kB
  • sloc: makefile: 2
file content (35 lines) | stat: -rw-r--r-- 682 bytes parent folder | download
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
package uidplus

import (
	"errors"

	"github.com/emersion/go-imap"
)

// An UID EXPUNGE command, as defined in RFC 4315 section 2.1.
type ExpungeCommand struct {
	SeqSet *imap.SeqSet
}

func (cmd *ExpungeCommand) Command() *imap.Command {
	return &imap.Command{
		Name:      "EXPUNGE",
		Arguments: []interface{}{cmd.SeqSet},
	}
}

func (cmd *ExpungeCommand) Parse(fields []interface{}) error {
	if len(fields) < 1 {
		return errors.New("Not enough arguments")
	}

	if seqSet, ok := fields[0].(string); !ok {
		return errors.New("Invalid sequence set")
	} else if seqSet, err := imap.ParseSeqSet(seqSet); err != nil {
		return err
	} else {
		cmd.SeqSet = seqSet
	}

	return nil
}