summaryrefslogtreecommitdiff
path: root/alot/commands/globals.py
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2018-02-12 00:52:03 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2018-02-12 14:15:51 +0100
commit54f85414c69bbf132b0eff3572e53172547b6252 (patch)
treea0be574847f27b866b02689325bf3589d104f502 /alot/commands/globals.py
parentd03cd3f582818651157aa9588e5723cdaa81dc3e (diff)
Add --tags argument to compose command
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'alot/commands/globals.py')
-rw-r--r--alot/commands/globals.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/alot/commands/globals.py b/alot/commands/globals.py
index 68f0a906..98021f3b 100644
--- a/alot/commands/globals.py
+++ b/alot/commands/globals.py
@@ -675,6 +675,8 @@ class HelpCommand(Command):
(['--sender'], {'nargs': '?', 'help': 'sender'}),
(['--template'], {'nargs': '?',
'help': 'path to a template message file'}),
+ (['--tags'], {'nargs': '?',
+ 'help': 'comma-separated list of tags to apply to message'}),
(['--subject'], {'nargs': '?', 'help': 'subject line'}),
(['--to'], {'nargs': '+', 'help': 'recipients'}),
(['--cc'], {'nargs': '+', 'help': 'copy to'}),
@@ -690,7 +692,7 @@ class ComposeCommand(Command):
"""compose a new email"""
def __init__(self, envelope=None, headers=None, template=None, sender=u'',
- subject=u'', to=None, cc=None, bcc=None, attach=None,
+ tags=None, subject=u'', to=None, cc=None, bcc=None, attach=None,
omit_signature=False, spawn=None, rest=None, encrypt=False,
**kwargs):
"""
@@ -704,6 +706,8 @@ class ComposeCommand(Command):
:type template: str
:param sender: From-header value
:type sender: str
+ :param tags: Comma-separated list of tags to apply to message
+ :type tags: list(str)
:param subject: Subject-header value
:type subject: str
:param to: To-header value
@@ -741,6 +745,7 @@ class ComposeCommand(Command):
self.force_spawn = spawn
self.rest = ' '.join(rest or [])
self.encrypt = encrypt
+ self.tags = tags
@inlineCallbacks
def apply(self, ui):
@@ -791,6 +796,8 @@ class ComposeCommand(Command):
self.envelope.add('Cc', ','.join(self.cc))
if self.bcc:
self.envelope.add('Bcc', ','.join(self.bcc))
+ if self.tags:
+ self.envelope.tags = [t for t in self.tags.split(',') if t]
# get missing From header
if 'From' not in self.envelope.headers:
@@ -892,7 +899,8 @@ class ComposeCommand(Command):
if settings.get('compose_ask_tags'):
comp = TagsCompleter(ui.dbman)
- tagsstring = yield ui.prompt('Tags', completer=comp)
+ tags = ','.join(self.tags) if self.tags else ''
+ tagsstring = yield ui.prompt('Tags', text=tags, completer=comp)
tags = [t for t in tagsstring.split(',') if t]
if tags is None:
raise CommandCanceled()