[njs] Reporting njs version by CLI.
Dmitry Volyntsev
xeioex at nginx.com
Fri Feb 9 16:17:49 UTC 2018
details: http://hg.nginx.org/njs/rev/624f79e326d5
branches:
changeset: 436:624f79e326d5
user: Dmitry Volyntsev <xeioex at nginx.com>
date: Fri Feb 09 19:16:18 2018 +0300
description:
Reporting njs version by CLI.
diffstat:
njs/njs.c | 14 ++++++++++++--
njs/test/njs_expect_test.exp | 5 ++---
2 files changed, 14 insertions(+), 5 deletions(-)
diffs (67 lines):
diff -r 2f266ec441c3 -r 624f79e326d5 njs/njs.c
--- a/njs/njs.c Fri Feb 09 19:16:18 2018 +0300
+++ b/njs/njs.c Fri Feb 09 19:16:18 2018 +0300
@@ -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 ar
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 ar
case 'h':
case '?':
- printf("Usage: %s [<file>|-] [-d]\n", argv[0]);
+ printf("Usage: %s [<file>|-] [-dV]\n", argv[0]);
return ret;
}
}
@@ -254,7 +264,7 @@ njs_interactive_shell(njs_opts_t *opts,
return NXT_ERROR;
}
- printf("interactive njscript\n\n");
+ printf("interactive njscript %s\n\n", NJS_VERSION);
printf("v.<Tab> -> the properties and prototype methods of v.\n");
printf("type console.help() for more information\n\n");
diff -r 2f266ec441c3 -r 624f79e326d5 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Fri Feb 09 19:16:18 2018 +0300
+++ b/njs/test/njs_expect_test.exp Fri Feb 09 19:16:18 2018 +0300
@@ -5,9 +5,8 @@
proc njs_test {body} {
spawn -nottycopy njs
- expect "interactive njscript\r
-\r
-v.<Tab> -> the properties and prototype methods of v.\r
+ expect -re "interactive njscript \\d+\.\\d+\.\\d+\r\n\r"
+ expect "v.<Tab> -> the properties and prototype methods of v.\r
type console.help() for more information\r
\r
>> "
More information about the nginx-devel
mailing list