diff options
author | Lucas Hoffmann <lucc@users.noreply.github.com> | 2018-02-15 17:42:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-15 17:42:42 +0100 |
commit | 4ea8f16d767cd24203f460398d5d6498a5bbe84c (patch) | |
tree | a0be574847f27b866b02689325bf3589d104f502 /alot | |
parent | d03cd3f582818651157aa9588e5723cdaa81dc3e (diff) | |
parent | 54f85414c69bbf132b0eff3572e53172547b6252 (diff) |
Merge pull request #1197 from kyrias/compose-tags
Add --tags argument to compose command
Diffstat (limited to 'alot')
-rw-r--r-- | alot/commands/globals.py | 12 |
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() |