Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
fix couchjs help language and use short options
Browse files Browse the repository at this point in the history
  • Loading branch information
tilgovi committed Oct 2, 2011
1 parent 76d9095 commit f2211f2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
12 changes: 6 additions & 6 deletions src/couchdb/priv/couch_js/help.h
Expand Up @@ -46,12 +46,12 @@ static const char USAGE_TEMPLATE[] =
"\n" "\n"
"Options:\n" "Options:\n"
"\n" "\n"
" -h, --help display a short help message and exit\n" " -h display a short help message and exit\n"
" -V, --version display version information and exit\n" " -V display version information and exit\n"
" -H, --http install %s cURL bindings (only avaiable\n" " -H enable %s cURL bindings (only avaiable\n"
" if package was built with cURL available)\n" " if package was built with cURL available)\n"
" --stack-size=SIZE specify that the interpreter should set the\n" " -S SIZE specify that the interpreter should set the\n"
" the stack quota for JS contexts to SIZE bytes\n" " the stack quota for JS contexts to SIZE bytes\n"
"\n" "\n"
"Report bugs at <%s>.\n"; "Report bugs at <%s>.\n";


Expand Down
21 changes: 5 additions & 16 deletions src/couchdb/priv/couch_js/util.c
Expand Up @@ -80,27 +80,16 @@ couch_parse_args(int argc, const char* argv[])
args->stack_size = 8L * 1024L; args->stack_size = 8L * 1024L;


while(i < argc) { while(i < argc) {
if(strcmp("-h", argv[i]) == 0 || if(strcmp("-h", argv[i]) == 0) {
strcmp("--help", argv[i]) == 0) {
DISPLAY_USAGE; DISPLAY_USAGE;
exit(0); exit(0);
} else if(strcmp("-V", argv[i]) == 0 || } else if(strcmp("-V", argv[i]) == 0) {
strcmp("--version", argv[i]) == 0) {
DISPLAY_VERSION; DISPLAY_VERSION;
exit(0); exit(0);
} else if(strcmp("-H", argv[i]) == 0 || } else if(strcmp("-H", argv[i]) == 0) {
strcmp("--http", argv[i]) == 0) {
args->use_http = 1; args->use_http = 1;
} else if(strncmp("--stack-size", argv[i], 12) == 0) { } else if(strcmp("-S", argv[i]) == 0) {
if(argv[i][12] == '\0') { args->stack_size = atoi(argv[++i]);
args->stack_size = atoi(argv[++i]);
} else if(argv[i][12] == '=') {
args->stack_size = atoi(argv[i]+13);
} else {
DISPLAY_USAGE;
exit(2);
}

if(args->stack_size <= 0) { if(args->stack_size <= 0) {
fprintf(stderr, "Invalid stack size.\n"); fprintf(stderr, "Invalid stack size.\n");
exit(2); exit(2);
Expand Down
2 changes: 1 addition & 1 deletion test/javascript/run.tpl
Expand Up @@ -27,4 +27,4 @@ cat $SCRIPT_DIR/json2.js \
$SCRIPT_DIR/test/*.js \ $SCRIPT_DIR/test/*.js \
$JS_TEST_DIR/couch_http.js \ $JS_TEST_DIR/couch_http.js \
$JS_TEST_DIR/cli_runner.js \ $JS_TEST_DIR/cli_runner.js \
| $COUCHJS --http - | $COUCHJS -H -

0 comments on commit f2211f2

Please sign in to comment.