From: Dmitry Volyntsev Date: Wed, 21 Nov 2018 13:45:10 +0000 (+0300) Subject: Interactive shell: quiet mode. X-Git-Tag: 0.2.6~10 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=2ab1bdae139b19adcf57d62f4c3667741239da76;p=njs.git Interactive shell: quiet mode. --- diff --git a/njs/njs_shell.c b/njs/njs_shell.c index 215a15d0..7bd5678c 100644 --- a/njs/njs_shell.c +++ b/njs/njs_shell.c @@ -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 argc, char** argv) "Interactive njs shell.\n" "\n" "Options:\n" - " -v print njs version and exit.\n" " -d print disassembled code.\n" + " -q disable interactive introduction prompt.\n" " -s sandbox mode.\n" + " -v print njs version and exit.\n" " | - run code from a file or stdin.\n"; ret = NXT_DONE; @@ -232,15 +234,19 @@ njs_get_options(njs_opts_t *opts, int argc, char** argv) 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, njs_vm_opt_t *vm_options) return NXT_ERROR; } - printf("interactive njs %s\n\n", NJS_VERSION); + if (!opts->quiet) { + printf("interactive njs %s\n\n", NJS_VERSION); - printf("v. -> the properties and prototype methods of v.\n"); - printf("type console.help() for more information\n\n"); + printf("v. -> the properties and prototype methods of v.\n"); + printf("type console.help() for more information\n\n"); + } for ( ;; ) { line.start = (u_char *) readline(">> "); diff --git a/njs/test/njs_expect_test.exp b/njs/test/njs_expect_test.exp index c04af8a4..5ca68029 100644 --- a/njs/test/njs_expect_test.exp +++ b/njs/test/njs_expect_test.exp @@ -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+"