aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--miragextract.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/miragextract.c b/miragextract.c
index 25259da..571f39a 100644
--- a/miragextract.c
+++ b/miragextract.c
@@ -176,18 +176,28 @@ void set_auto_name(void) {
outfilebase = autoname;
}
-void usage(int exit_code) {
- fprintf(exit_code ? stderr : stdout,
+void usage(void) {
+ char spaces[42];
+ int i, count;
+
+ count = strlen(self) + 8;
+ if(count >= 40) count = 40;
+
+ for(i = 0; i < count; i++)
+ spaces[i] = ' ';
+ spaces[i] = '\0';
+
+ printf(
"miragextract v" VERSION " by B. Watson, WTFPL\n"
"Usage: %s [-l] [-s] [-n] [-a] [-d] [-t track] [-b base]\n"
- " [-f fmt ] [-q quality ] image-file\n"
- "See man page for details\n", self);
- exit(exit_code);
+ "%s[-f fmt] [-q quality] image-file\n"
+ "See man page for details\n", self, spaces);
+ exit(0);
}
void parse_args(int argc, char **argv) {
- if(argc == 1) usage(0);
- if(argc > 1 && strcmp(argv[1], "--help") == 0) usage(0);
+ if(argc == 1) usage();
+ if(argc > 1 && strcmp(argv[1], "--help") == 0) usage();
while(++argv, --argc) {
if(argv[0][0] == '-') {