diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-05-17 17:53:57 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-05-17 17:53:57 -0400 |
commit | 6bec820cb9d015e99e4f5bf375fba098ba5b2f30 (patch) | |
tree | 9f532515dd773ca78d11b2d49e3592ed4e7b1c6a /b4/__init__.py | |
parent | 9f55eb98f036616f6611c5d605072008d5855356 (diff) | |
download | b4-6bec820cb9d015e99e4f5bf375fba098ba5b2f30.tar.gz |
Allow passing entire mbox via stdin
Per request, allow passing entire mbox files via stdin, allowing fully
pipe-through operation from something like mutt:
b4 am -sl -m - -o -
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Link: https://lore.kernel.org/tools/YFETLu8TKWI2WlSF@hirez.programming.kicks-ass.net
Diffstat (limited to 'b4/__init__.py')
-rw-r--r-- | b4/__init__.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index 7e4295e..43fd078 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1956,20 +1956,19 @@ def get_msgid_from_stdin(): if not sys.stdin.isatty(): message = email.message_from_string(sys.stdin.read()) return message.get('Message-ID', None) - logger.error('Error: pipe a message or pass msgid as parameter') - sys.exit(1) + return None -def get_msgid(cmdargs): +def get_msgid(cmdargs) -> Optional[str]: if not cmdargs.msgid: logger.debug('Getting Message-ID from stdin') msgid = get_msgid_from_stdin() - if msgid is None: - logger.error('Unable to find a valid message-id in stdin.') - sys.exit(1) else: msgid = cmdargs.msgid + if msgid is None: + return None + msgid = msgid.strip('<>') # Handle the case when someone pastes a full URL to the message matches = re.search(r'^https?://[^/]+/([^/]+)/([^/]+@[^/]+)', msgid, re.IGNORECASE) |