diff options
author | B. Watson <yalhcru@gmail.com> | 2020-05-07 15:32:52 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2020-05-07 15:32:52 -0400 |
commit | b3eed2c9f183c34458e0e2e40028990fd2173b86 (patch) | |
tree | c0b782cf49cb714512969f35bac1465f49172e00 | |
parent | f1e13269603e63a590aa044c9394f5678e356e36 (diff) | |
download | miragextract-b3eed2c9f183c34458e0e2e40028990fd2173b86.tar.gz |
fussy formatting in usage()
-rw-r--r-- | miragextract.c | 24 |
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] == '-') { |