From: Dmitry Volyntsev Date: Fri, 9 Feb 2018 16:16:18 +0000 (+0300) Subject: Reporting njs version by CLI. X-Git-Tag: 0.2.0~47 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=0c386a5ba2984e4ea3c957e96539fd322b22de77;p=njs.git Reporting njs version by CLI. --- diff --git a/njs/njs.c b/njs/njs.c index 80c7ed8d..5c97b524 100644 --- a/njs/njs.c +++ b/njs/njs.c @@ -41,6 +41,7 @@ typedef enum { typedef struct { char *file; + nxt_int_t version; nxt_int_t disassemble; nxt_int_t interactive; } njs_opts_t; @@ -137,6 +138,11 @@ main(int argc, char **argv) return (ret == NXT_DONE) ? EXIT_SUCCESS : EXIT_FAILURE; } + if (opts.version != 0) { + printf("%s\n", NJS_VERSION); + return EXIT_SUCCESS; + } + mcp = nxt_mem_cache_pool_create(&njs_vm_mem_cache_pool_proto, NULL, NULL, 2 * nxt_pagesize(), 128, 512, 16); if (nxt_slow_path(mcp == NULL)) { @@ -189,6 +195,10 @@ njs_get_options(njs_opts_t *opts, int argc, char** argv) opts->disassemble = 1; break; + case 'V': + opts->version = 1; + break; + default: fprintf(stderr, "Unknown argument: \"%s\"\n", argv[i]); ret = NXT_ERROR; @@ -197,7 +207,7 @@ njs_get_options(njs_opts_t *opts, int argc, char** argv) case 'h': case '?': - printf("Usage: %s [|-] [-d]\n", argv[0]); + printf("Usage: %s [|-] [-dV]\n", argv[0]); return ret; } } @@ -254,7 +264,7 @@ njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options) return NXT_ERROR; } - printf("interactive njscript\n\n"); + printf("interactive njscript %s\n\n", NJS_VERSION); printf("v. -> the properties and prototype methods of v.\n"); printf("type console.help() for more information\n\n"); diff --git a/njs/test/njs_expect_test.exp b/njs/test/njs_expect_test.exp index 20d9feb9..ea04155f 100644 --- a/njs/test/njs_expect_test.exp +++ b/njs/test/njs_expect_test.exp @@ -5,9 +5,8 @@ proc njs_test {body} { spawn -nottycopy njs - expect "interactive njscript\r -\r -v. -> the properties and prototype methods of v.\r + expect -re "interactive njscript \\d+\.\\d+\.\\d+\r\n\r" + expect "v. -> the properties and prototype methods of v.\r type console.help() for more information\r \r >> "