Skip to content

Commit e506686

Browse files
committed
Pipeto specific mime part format.
While `pipeto --format mimepart` pipes whichever part is currently selected, the 'html' and 'plain' formats override the selected mime part (and preferences in settings). This is useful because the mime type you want displayed in alot isn't necessarily the one you want piped and also for setting keybindings to pipe specific mime types to specific applications (plain -> text editor, html -> web browser).
1 parent 5c0aefb commit e506686

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

alot/commands/thread.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,8 @@ def matches(msgt):
633633
(['--all'], {'action': 'store_true', 'help': 'pass all messages'}),
634634
(['--format'], {'help': 'output format', 'default': 'raw',
635635
'choices': [
636-
'raw', 'decoded', 'id', 'filepath', 'mimepart']}),
636+
'raw', 'decoded', 'id', 'filepath', 'mimepart',
637+
'plain', 'html']}),
637638
(['--separately'], {'action': 'store_true',
638639
'help': 'call command once for each message'}),
639640
(['--background'], {'action': 'store_true',
@@ -744,7 +745,9 @@ async def apply(self, ui):
744745
bodytext = msg.get_body_text()
745746
msgtext = '%s\n\n%s' % (headertext, bodytext)
746747
pipestrings.append(msgtext)
747-
elif self.output_format == 'mimepart':
748+
elif self.output_format in ['mimepart', 'plain', 'html']:
749+
if self.output_format in ['plain', 'html']:
750+
mimepart = get_body_part(mail, self.output_format)
748751
pipestrings.append(string_sanitize(remove_cte(
749752
msg.mime_part, as_string=True)))
750753

docs/source/usage/modes/thread.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The following commands are available in thread mode:
7272

7373
optional arguments
7474
:---all: pass all messages
75-
:---format: output format; valid choices are: 'raw','decoded','id','filepath','mimepart' (defaults to: 'raw')
75+
:---format: output format; valid choices are: 'raw','decoded','id','filepath','mimepart','plain','html' (defaults to: 'raw')
7676
:---separately: call command once for each message
7777
:---background: don't stop the interface
7878
:---add_tags: add 'Tags' header to the message

0 commit comments

Comments
 (0)