summary refs log tree commit diff stats
path: root/config/binds.conf
Commit message (Expand)AuthorAgeFilesLines
* Add delete to the default binds.confDrew DeVault2019-06-021-0/+1
* Add :save and :pipe commands to viewerGalen Abell2019-05-271-0/+1
* Implement :edit in compose screenDrew DeVault2019-05-261-0/+1
* binds.conf: make reply -a easier to use than replyDrew DeVault2019-05-251-4/+4
* Bind :compose to C in binds.confFrancis Dinh2019-05-231-0/+2
* Implement :next-part, :prev-partDrew DeVault2019-05-201-0/+2
* Rename :delete-message et al to :delete et alDrew DeVault2019-05-191-14/+14
* Change default bindings for repliesDrew DeVault2019-05-161-4/+4
* Change default reply keybindingsDrew DeVault2019-05-161-8/+8
* Fix default bindings for quit and editDrew DeVault2019-05-141-1/+4
* Move ! bind to [messages]Drew DeVault2019-05-141-1/+1
* Add (non-functional) reply commands to bindingsDrew DeVault2019-05-141-2/+9
* Add ! to default keybindingsDrew DeVault2019-05-141-0/+1
* Add distinct keybindings for each compose viewDrew DeVault2019-05-141-0/+13
* Add initial compose widgetDrew DeVault2019-05-121-0/+8
* Add message view commands, :closeDrew DeVault2019-03-301-1/+1
* Update default config/binds.confDrew DeVault2019-03-301-2/+17
* Add context-specific keybindingsDrew DeVault2019-03-211-0/+32
DD; font-weight: bold } /* Literal.Number.Integer.Long */
package worker

import (
	"git.sr.ht/~sircmpwn/aerc/worker/imap"
	"git.sr.ht/~sircmpwn/aerc/worker/types"

	"fmt"
	"log"
	"net/url"
	"strings"
)

// Guesses the appropriate worker type based on the given source string
func NewWorker(source string, logger *log.Logger) (*types.Worker, error) {
	u, err := url.Parse(source)
	if err != nil {
		return nil, err
	}
	worker := types.NewWorker(logger)
	scheme := u.Scheme
	if strings.ContainsRune(scheme, '+') {
		scheme = scheme[:strings.IndexRune(scheme, '+')]
		fmt.Println(scheme)
	}
	switch scheme {
	case "imap":
		fallthrough
	case "imaps":
		worker.Backend = imap.NewIMAPWorker(worker)
	default:
		return nil, fmt.Errorf("Unknown backend %s", u.Scheme)
	}
	return worker, nil
}