From 12ee0b9763542151a86fa8bbdef5ea91bc0bdfdb Mon Sep 17 00:00:00 2001 From: Patrick Totzke Date: Sat, 15 Oct 2011 13:31:23 +0100 Subject: decorate globals:compose --- alot/commands/globals.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'alot/commands/globals.py') diff --git a/alot/commands/globals.py b/alot/commands/globals.py index d9cd10db..6484b3e2 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -341,10 +341,19 @@ class HelpCommand(Command): ui.show_as_root_until_keypress(overlay, 'cancel') -@registerCommand(MODE, 'compose', {}) +@registerCommand(MODE, 'compose', arguments=[ + (['--sender'], {'nargs': '?', 'help':'sender'}), + (['--subject'], {'nargs':'?', 'help':'subject line'}), + (['--to'], {'nargs':'+', 'help':'recipient'}), + (['--cc'], {'nargs':'+', 'help':'copy to'}), + (['--bcc'], {'nargs':'+', 'help':'blind copy to'}), +] +) class ComposeCommand(Command): """compose a new email and open an envelope for it""" - def __init__(self, mail=None, headers={}, **kwargs): + def __init__(self, mail=None, headers={}, + sender=u'', subject=u'', to=[], cc=[], bcc=[], + **kwargs): Command.__init__(self, **kwargs) if not mail: self.mail = MIMEMultipart() @@ -354,6 +363,18 @@ class ComposeCommand(Command): for key, value in headers.items(): self.mail[key] = encode_header(key, value) + if sender: + self.mail['From'] = encode_header('From', sender) + if subject: + self.mail['Subject'] = encode_header('Subject', subject) + if to: + self.mail['To'] = encode_header('To', ','.join(to)) + if cc: + self.mail['Cc'] = encode_header('Cc', ','.join(cc)) + if bcc: + self.mail['Bcc'] = encode_header('Bcc', ','.join(bcc)) + + @defer.inlineCallbacks def apply(self, ui): # TODO: fill with default header (per account) -- cgit v1.2.3