Skip to content

Commit

Permalink
Merge pull request galaxyproject#17191 from natefoo/secret-decoder-ri…
Browse files Browse the repository at this point in the history
…ng-nargs

Accept any number of arguments to the secret decoder ring
  • Loading branch information
natefoo authored Dec 15, 2023
2 parents d0c78d5 + a973e05 commit 79db9c1
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 79db9c1

Please sign in to comment.