# HG changeset patch # User Paul Boddie # Date 1482248624 -3600 # Node ID f12ef637a7dd77dbcf8644542131dac28c5780a6 # Parent 5b39e2df8e80be3bdb1540281c35f3f97f84ce27 Added documentation and copyright information to the showmail script. diff -r 5b39e2df8e80 -r f12ef637a7dd tools/showmail.py --- a/tools/showmail.py Tue Dec 20 16:06:49 2016 +0100 +++ b/tools/showmail.py Tue Dec 20 16:43:44 2016 +0100 @@ -1,7 +1,27 @@ #!/usr/bin/env python +""" +Show a MIME-encoded e-mail message as plain text. + +Copyright (C) 2015, 2016 Paul Boddie + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 3 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see . +""" + from email import message_from_string from email.generator import Generator +from os.path import split import sys try: @@ -61,6 +81,18 @@ # Main program. if __name__ == "__main__": + if len(sys.argv) > 1 and sys.argv[1] == "--help": + print >>sys.stderr, """\ +Usage: %s [ ] + +Read MIME-encoded e-mail messages from standard input, writing the decoded +messages to standard output. + +Where is given, the indicated number of messages will be +skipped in the input, with the first subsequent message being written out. +""" % split(sys.argv[0])[1] + sys.exit(1) + skip = int((sys.argv[1:] or [0])[0]) message = message_from_string(until_from(sys.stdin, skip)) decode(message)