Welcome! Log In Create A New Profile

Advanced

[njs] Interactive shell: quiet mode.

Dmitry Volyntsev
November 21, 2018 08:48AM
details: http://hg.nginx.org/njs/rev/db44b92af5f7
branches:
changeset: 661:db44b92af5f7
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed Nov 21 16:45:10 2018 +0300
description:
Interactive shell: quiet mode.

diffstat:

njs/njs_shell.c | 24 ++++++++++++++++--------
njs/test/njs_expect_test.exp | 4 ++++
2 files changed, 20 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r 6f29f93b0390 -r db44b92af5f7 njs/njs_shell.c
--- a/njs/njs_shell.c Mon Nov 19 16:55:37 2018 +0300
+++ b/njs/njs_shell.c Wed Nov 21 16:45:10 2018 +0300
@@ -33,6 +33,7 @@ typedef struct {
nxt_int_t disassemble;
nxt_int_t interactive;
nxt_int_t sandbox;
+ nxt_int_t quiet;
} njs_opts_t;


@@ -203,9 +204,10 @@ njs_get_options(njs_opts_t *opts, int ar
"Interactive njs shell.\n"
"\n"
"Options:\n"
+ " -d print disassembled code.\n"
+ " -q disable interactive introduction prompt.\n"
+ " -s sandbox mode.\n"
" -v print njs version and exit.\n"
- " -d print disassembled code.\n"
- " -s sandbox mode.\n"
" <filename> | - run code from a file or stdin.\n";

ret = NXT_DONE;
@@ -232,15 +234,19 @@ njs_get_options(njs_opts_t *opts, int ar
opts->disassemble = 1;
break;

- case 'v':
- case 'V':
- opts->version = 1;
+ case 'q':
+ opts->quiet = 1;
break;

case 's':
opts->sandbox = 1;
break;

+ case 'v':
+ case 'V':
+ opts->version = 1;
+ break;
+
default:
fprintf(stderr, "Unknown argument: \"%s\" "
"try \"%s -h\" for available options\n", argv[i], argv[0]);
@@ -309,10 +315,12 @@ njs_interactive_shell(njs_opts_t *opts,
return NXT_ERROR;
}

- printf("interactive njs %s\n\n", NJS_VERSION);
+ if (!opts->quiet) {
+ printf("interactive njs %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");
+ printf("v.<Tab> -> the properties and prototype methods of v.\n");
+ printf("type console.help() for more information\n\n");
+ }

for ( ;; ) {
line.start = (u_char *) readline(">> ");
diff -r 6f29f93b0390 -r db44b92af5f7 njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp Mon Nov 19 16:55:37 2018 +0300
+++ b/njs/test/njs_expect_test.exp Wed Nov 21 16:45:10 2018 +0300
@@ -522,6 +522,10 @@ njs_test {

# CLI OPTIONS

+# help
+
+njs_run "-h" "Interactive njs shell.\r\n\r\nOptions:"
+
# version

njs_run "-v" "\\d+\.\\d+\.\\d+"
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Interactive shell: quiet mode.

Dmitry Volyntsev 356 November 21, 2018 08:48AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready