summaryrefslogtreecommitdiff
path: root/email-print-mime-structure
diff options
context:
space:
mode:
Diffstat (limited to 'email-print-mime-structure')
-rwxr-xr-xemail-print-mime-structure15
1 files changed, 15 insertions, 0 deletions
diff --git a/email-print-mime-structure b/email-print-mime-structure
index 5497597..aac8194 100755
--- a/email-print-mime-structure
+++ b/email-print-mime-structure
@@ -1,4 +1,5 @@
#!/usr/bin/env python3
+# PYTHON_ARGCOMPLETE_OK
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Daniel Kahn Gillmor
@@ -45,6 +46,11 @@ try:
except ImportError:
pgpy = None
+try:
+ import argcomplete #type: ignore
+except ImportError:
+ argcomplete = None
+
class MimePrinter(object):
def __init__(self, args:Namespace):
self.args = args
@@ -152,6 +158,15 @@ def main() -> None:
parser.add_argument('--use-gpg-agent', metavar='true|false', type=bool,
default=False,
help='Ask local GnuPG installation for decryption')
+
+ if argcomplete:
+ argcomplete.autocomplete(parser)
+ elif '_ARGCOMPLETE' in os.environ:
+ logging.error('Argument completion requested but the "argcomplete" '
+ 'module is not installed. '
+ 'Maybe you want to "apt install python3-argcomplete"')
+ sys.exit(1)
+
args:Namespace = parser.parse_args()
msg:Union[Message, str, int, Any] = email.message_from_file(sys.stdin)