Skip to content

Commit

Permalink
Accept any number of arguments to the secret decoder ring
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Dec 14, 2023
1 parent 207ecc7 commit a973e05
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/secret_decoder_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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")

0 comments on commit a973e05

Please sign in to comment.