allow user to specify they want input to be encrypted unconditionally

This commit is contained in:
revsuine 2024-11-12 14:27:20 +00:00
parent 4fed606df2
commit 40b3ba3760
Signed by: revsuine
GPG key ID: 3F257B68F5BC9339

View file

@ -126,6 +126,8 @@ def main() -> None:
parser.add_argument('--encoding', action="store", default=DEFAULT_ENCODING, parser.add_argument('--encoding', action="store", default=DEFAULT_ENCODING,
required=False, required=False,
help="Encoding to use for the gnupg.GPG object") help="Encoding to use for the gnupg.GPG object")
parser.add_argument('--unconditional', action="store_true",
help="Encrypt mail unconditionally. By default, mail is not encrypted if it is already encrypted.")
parser.add_argument('recipient', nargs='*', parser.add_argument('recipient', nargs='*',
help="Key ID or email of keys to encrypt for") help="Key ID or email of keys to encrypt for")
args = parser.parse_args() args = parser.parse_args()
@ -134,7 +136,12 @@ def main() -> None:
if args.decrypt: if args.decrypt:
sys.stdout.write(decrypt(msg), encoding=args.encoding) sys.stdout.write(decrypt(msg), encoding=args.encoding)
else: else:
sys.stdout.write(encrypt(msg, args.recipient, encoding=args.encoding)) sys.stdout.write(encrypt(
msg,
args.recipient,
unconditionally_encrypt=args.unconditional,
encoding=args.encoding
))
if __name__ == '__main__': if __name__ == '__main__':
main() main()