diff options
author | Robert Newson <robert.newson@cloudant.com> | 2011-10-10 17:55:50 +0100 |
---|---|---|
committer | Robert Newson <robert.newson@cloudant.com> | 2011-10-10 19:04:54 +0100 |
commit | cf630a2e87ac1b6eace26601dc5b7ffdb39273b2 (patch) | |
tree | fe5080dedf417b20112ed372d737eb8c3ca309ff /couchjs/c_src/util.c | |
parent | 6e6523d62beff627c444aec3d658ef1a5d534ff1 (diff) | |
parent | da22c19f7a7fdfae015dfb0db93b5bd9453eae6c (diff) |
Merge remote-tracking branch 'apache/1.1.x'
Diffstat (limited to 'couchjs/c_src/util.c')
-rw-r--r-- | couchjs/c_src/util.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/couchjs/c_src/util.c b/couchjs/c_src/util.c index f5ef3e82..bd7be4c9 100644 --- a/couchjs/c_src/util.c +++ b/couchjs/c_src/util.c @@ -13,6 +13,7 @@ #include <stdlib.h> #include <string.h> +#include "help.h" #include "util.h" #include "utf8.h" @@ -77,15 +78,30 @@ couch_parse_args(int argc, const char* argv[]) args->stack_size = 8L * 1024L; while(i < argc) { - if(strcmp("--http", argv[i]) == 0) { + if(strcmp("-h", argv[i]) == 0) { + DISPLAY_USAGE; + exit(0); + } else if(strcmp("-V", argv[i]) == 0) { + DISPLAY_VERSION; + exit(0); + } else if(strcmp("-H", argv[i]) == 0) { args->use_http = 1; - } else if(strcmp("--stack-size", argv[i]) == 0) { - args->stack_size = atoi(argv[i+1]); + } else if(strcmp("-S", argv[i]) == 0) { + args->stack_size = atoi(argv[++i]); if(args->stack_size <= 0) { fprintf(stderr, "Invalid stack size.\n"); exit(2); } + } else if(strcmp("--", argv[i]) == 0) { + i++; + break; } else { + break; + } + i++; + } + + while(i < argc) { args->script = slurp_file(args->script, argv[i]); if(args->script_name == NULL) { if(strcmp(argv[i], "-") == 0) { @@ -96,12 +112,11 @@ couch_parse_args(int argc, const char* argv[]) } else { args->script_name = "<multiple_files>"; } - } i++; } if(args->script_name == NULL || args->script == NULL) { - fprintf(stderr, "No script provided.\n"); + DISPLAY_USAGE; exit(3); } |