IMAP LSUB Command Parser (command/lsub.go)

gluon · imap/command/lsub.go · go · MIT
email, dev-tools, cli, lang:go

Go parser for the IMAP LSUB command that extracts mailbox and list-mailbox arguments using RFC-compliant token consumption.

// Source: https://github.com/ProtonMail/gluon | License: MIT | Copyright 2020 James Houlahan
// Provided via justclaw.it.com; keep this notice with the code.
package command

import (
	"fmt"

	"github.com/ProtonMail/gluon/rfcparser"
)

type LSub struct {
	Mailbox     string
	LSubMailbox string
}

func (l LSub) String() string {
	return fmt.Sprintf("LSUB '%v' '%v'", l.Mailbox, l.LSubMailbox)
}

func (l LSub) SanitizedString() string {
	return l.String()
}

type LSubCommandParser struct{}

func (LSubCommandParser) FromParser(p *rfcparser.Parser) (Payload, error) {
	// lsub            = "LSUB" SP mailbox SP list-mailbox
	if err := p.Consume(rfcparser.TokenTypeSP, "expected space after command"); err != nil {
		return nil, err
	}

	mailbox, err := ParseMailbox(p)
	if err != nil {
		return nil

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key