diff options
author | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-05-05 14:02:04 +0200 |
---|---|---|
committer | Pieter Noordhuis <pcnoordhuis@gmail.com> | 2010-05-05 14:02:04 +0200 |
commit | 57ca68acc16cedb39409ce5e513f9c2dd6f29182 (patch) | |
tree | 05c8dfdd167afef5e44457612ff3383f9d43826b /redis-check-aof.c | |
parent | e795c7588875c47908c06a5fac0f869e23854218 (diff) | |
download | redis-57ca68acc16cedb39409ce5e513f9c2dd6f29182.tar.gz |
moved argument parsing around
Diffstat (limited to 'redis-check-aof.c')
-rw-r--r-- | redis-check-aof.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/redis-check-aof.c b/redis-check-aof.c index 31abe1be9..534720321 100644 --- a/redis-check-aof.c +++ b/redis-check-aof.c @@ -125,25 +125,23 @@ long process(FILE *fp) { } int main(int argc, char **argv) { - /* expect the first argument to be the dump file */ - if (argc <= 1) { - printf("Usage: %s [--fix] <file.aof>\n", argv[0]); - exit(0); - } - char *filename; int fix = 0; - if (argc == 3) { + + if (argc < 2) { + printf("Usage: %s [--fix] <file.aof>\n", argv[0]); + exit(1); + } else if (argc == 2) { + filename = argv[1]; + } else if (argc == 3) { if (strcmp(argv[1],"--fix") != 0) { printf("Invalid argument: %s\n", argv[1]); exit(1); } - fix = 1; filename = argv[2]; - } else if (argc == 2) { - filename = argv[1]; + fix = 1; } else { - printf("Invalid argument"); + printf("Invalid arguments\n"); exit(1); } |