From a973e0518bf07080b638b81bf48682eec30a7e81 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Thu, 14 Dec 2023 13:07:37 -0500 Subject: [PATCH] Accept any number of arguments to the secret decoder ring --- scripts/secret_decoder_ring.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/secret_decoder_ring.py b/scripts/secret_decoder_ring.py index 8b14d23900b4..5bb09a330b1c 100644 --- a/scripts/secret_decoder_ring.py +++ b/scripts/secret_decoder_ring.py @@ -20,8 +20,8 @@ log = logging.getLogger(__name__) parser = argparse.ArgumentParser() -parser.add_argument("action", metavar="ACTION", type=str, default=None, help="decode|encode") -parser.add_argument("value", metavar="VALUE", type=str, default=None, help="value to encode or decode") +parser.add_argument("action", metavar="ACTION", type=str, default=None, choices=("decode", "encode")) +parser.add_argument("value", metavar="VALUE", nargs="+", type=str, default=None, help="value to encode or decode") populate_config_args(parser) args = parser.parse_args() @@ -39,9 +39,10 @@ # Login manager to manage current_user functionality if args.action == "decode": - sys.stdout.write(security_helper.decode_guid(args.value.lstrip("F"))) + for value in args.value: + sys.stdout.write(security_helper.decode_guid(value.lstrip("F"))) + sys.stdout.write("\n") elif args.action == "encode": - sys.stdout.write(unicodify(security_helper.encode_guid(args.value))) -else: - sys.stdout.write("Unknown argument") -sys.stdout.write("\n") + for value in args.value: + sys.stdout.write(unicodify(security_helper.encode_guid(value))) + sys.stdout.write("\n")