use a shorter usage description after errors

This commit is contained in:
Erik Auerswald
2018-07-27 22:04:56 +02:00
parent 6e8a7855df
commit a5d77497ee
3 changed files with 12 additions and 3 deletions
+8
View File
@@ -74,6 +74,14 @@ void print_version(FILE *f)
" under the terms\nof the GNU GPL (version 3 or later)\n");
}
/* print short usage */
void short_usage(char *name, FILE *f)
{
fprintf(f, "\nUsage: %s [OPTION]... [COMMAND]... IMAGE\n", name);
fprintf(f, "Use '%s --help' to print long help describing all options\n",
name);
}
/* print usage */
void usage(char *name, FILE *f)
{
+1
View File
@@ -22,6 +22,7 @@
/* functions */
/* print usage */
void short_usage(char *name, FILE *f);
void usage(char *name, FILE *f);
/* print help for luminance functions */
+3 -3
View File
@@ -358,7 +358,7 @@ int main(int argc, char **argv)
}
break;
case '?': /* missing argument or character not in optstring */
usage(argv[0],stderr);
short_usage(argv[0],stderr);
exit (2);
break;
default: /* this should not be reached */
@@ -370,7 +370,7 @@ int main(int argc, char **argv)
fprintf (stderr,
"error: getopt returned unhandled character code %X\n", c);
}
usage(argv[0], stderr);
short_usage(argv[0], stderr);
exit(99);
}
}
@@ -400,7 +400,7 @@ int main(int argc, char **argv)
/* if no argument left exit the program */
if(optind >= argc) {
fprintf(stderr, "error: no image filename given\n");
usage(argv[0], stderr);
short_usage(argv[0], stderr);
exit(99);
}
if(flags & DEBUG_OUTPUT) {