aerc

Working clone of aerc-mail.org
git clone git://git.danielmoch.com/aerc.git
Log | Files | Refs | README | LICENSE

pipe.go (669B)


      1 package account
      2 
      3 import (
      4 	"errors"
      5 	"io"
      6 
      7 	"git.sr.ht/~sircmpwn/aerc/commands"
      8 	"git.sr.ht/~sircmpwn/aerc/widgets"
      9 )
     10 
     11 func init() {
     12 	register("pipe", Pipe)
     13 }
     14 
     15 func Pipe(aerc *widgets.Aerc, args []string) error {
     16 	if len(args) < 2 {
     17 		return errors.New("Usage: :pipe <cmd> [args...]")
     18 	}
     19 	acct := aerc.SelectedAccount()
     20 	store := acct.Messages().Store()
     21 	msg := acct.Messages().Selected()
     22 	store.FetchFull([]uint32{msg.Uid}, func(reader io.Reader) {
     23 		term, err := commands.QuickTerm(aerc, args[1:], reader)
     24 		if err != nil {
     25 			aerc.PushError(" " + err.Error())
     26 			return
     27 		}
     28 		name := args[1] + " <" + msg.Envelope.Subject
     29 		aerc.NewTab(term, name)
     30 	})
     31 	return nil
     32 }