summaryrefslogtreecommitdiff
path: root/alot/commands
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2011-10-15 13:31:23 +0100
committerPatrick Totzke <patricktotzke@gmail.com>2011-10-15 13:31:23 +0100
commit12ee0b9763542151a86fa8bbdef5ea91bc0bdfdb (patch)
tree55d61e938ed2973b1ad9b670bd62dd0bd02a320b /alot/commands
parent9c7da9f4e5decf92b36480a52647f5d409806dbc (diff)
decorate globals:compose
Diffstat (limited to 'alot/commands')
-rw-r--r--alot/commands/globals.py25
1 files changed, 23 insertions, 2 deletions
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)