@@ -14,8 +14,6 @@ def fix_optionparser_whitespace(input):
1414 doublespace = '\033 [8m.\033 [0m' * 2
1515 return input .replace (' ' , doublespace ).replace ('\n ' , newline )
1616
17-
18-
1917def main ():
2018 """Encodes or decodes JSON Web Tokens based on input
2119
@@ -24,7 +22,7 @@ Decoding examples:
2422 %prog --key=secret json.web.token
2523 %prog --no-verify json.web.token
2624
27- Encoding requires the key argument and takes space separated key/value pairs
25+ Encoding requires the key option and takes space separated key/value pairs
2826separated by equals (=) as input. Examples:
2927
3028 %prog --key=secret iss=me exp=1302049071
@@ -58,7 +56,7 @@ The exp key is special and can take an offset to current Unix time.
5856 sys .exit (0 )
5957 except jwt .DecodeError , e :
6058 print e
61- sys .exit (0 )
59+ sys .exit (1 )
6260 except jwt .DecodeError :
6361 pass
6462
@@ -72,7 +70,7 @@ The exp key is special and can take an offset to current Unix time.
7270 for arg in arguments :
7371 try :
7472 k ,v = arg .split ('=' , 1 )
75- # exp special case?
73+ # exp +offset special case?
7674 if k == 'exp' and v [0 ] == '+' and len (v ) > 1 :
7775 v = str (int (time .time ()+ int (v [1 :])))
7876 # Cast to integer?
@@ -95,8 +93,10 @@ The exp key is special and can take an offset to current Unix time.
9593
9694 try :
9795 print jwt .encode (payload , key = options .key , algorithm = options .algorithm )
96+ sys .exit (0 )
9897 except Exception , e :
9998 print e
99+ sys .exit (1 )
100100 else :
101101 p .print_help ()
102102
0 commit comments