@@ -42,7 +42,7 @@ Generate and (optionally) sign a JSON Web Token\n\
4242 v The value of the claim. For integer, must be parsable\n\
4343 by strtol(). For boolean, if the value starts with 'f',\n\
4444 'F', or '0' it is taken as false. Anything else is true.\n\
45- -j, --json=STRING JSON string to be used as the body of the token\n\
45+ -j, --json=STRING JSON string to be used as the body of the token. \n\
4646 -q, --quiet No output other than the generated token\n\
4747 -v, --verbose Show encoded header and payload while verifying. Note that\n\
4848 the header will not who the 'tpy' and 'alg' attributes\n\
@@ -51,7 +51,8 @@ Generate and (optionally) sign a JSON Web Token\n\
5151This program will encode and sign a token in JWT format.\n\
5252\n\
5353For the --print option, output will be piped to the command's stdin. This\n\
54- is useful if you wanted to use something like `jq -C`.\n\
54+ is useful if you wanted to use something like `jq -C` to colorize it. A\n\
55+ non-0 exit status will stop the token from getting generated.\n\
5556\n\
5657If you need to convert a key to JWT (e.g. from PEM or DER format) see\n\
5758key2jwk(1).\n" , __progname );
@@ -135,18 +136,23 @@ int main(int argc, char *argv[])
135136
136137 case 'c' :
137138 t = strtok (optarg , ":" );
138- if (t == NULL )
139- usage ("Invalid --claim format" ,
140- EXIT_FAILURE );
139+ if (t == NULL ) {
140+ fprintf (stderr , "Invalid claim format [%s]\n" ,
141+ optarg );
142+ exit (EXIT_FAILURE );
143+ }
141144 k = strtok (NULL , "=" );
142- if (k == NULL )
143- usage ("Invalid --claim format" ,
144- EXIT_FAILURE );
145-
145+ if (k == NULL ) {
146+ fprintf (stderr , "Invalid claim format [%s]\n" ,
147+ optarg );
148+ exit (EXIT_FAILURE );
149+ }
146150 v = strtok (NULL , "=" );
147- if (v == NULL )
148- usage ("Invalid --claim format" ,
149- EXIT_FAILURE );
151+ if (v == NULL ) {
152+ fprintf (stderr , "Invalid claim format [%s]\n" ,
153+ optarg );
154+ exit (EXIT_FAILURE );
155+ }
150156
151157 switch (t [0 ]) {
152158 case 's' :
@@ -230,7 +236,8 @@ int main(int argc, char *argv[])
230236 if (json ) {
231237 jwt_set_ADD_JSON (& jval , NULL , json );
232238 if (jwt_builder_claim_add (builder , & jval )) {
233- fprintf (stderr , "Error adding json\n" );
239+ fprintf (stderr , "Error adding JSON (%d)\n" ,
240+ jval .error );
234241 exit (EXIT_FAILURE );
235242 }
236243 }
0 commit comments