Skip to content

Commit

Permalink
Merge 09cbf06 into e1e4d02
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Nov 5, 2017
2 parents e1e4d02 + 09cbf06 commit 2e473ff
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions jwt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ def encode_payload(args):

def decode_payload(args):
try:
if sys.stdin.isatty():
token = sys.stdin.read()
else:
if args.token:
token = args.token
else:
if sys.stdin.isatty():
token = sys.stdin.readline().strip()
else:
raise IOError('Cannot read from stdin: terminal not a TTY')

token = token.encode('utf-8')
data = decode(token, key=args.key, verify=args.verify)
Expand Down Expand Up @@ -133,7 +136,10 @@ def build_argparser():

# Decode subcommand
decode_parser = subparsers.add_parser('decode', help='use to decode a supplied JSON web token')
decode_parser.add_argument('token', help='JSON web token to decode.')
decode_parser.add_argument(
'token',
help='JSON web token to decode.',
nargs='?')

decode_parser.add_argument(
'-n', '--no-verify',
Expand Down

0 comments on commit 2e473ff

Please sign in to comment.