]> git.kaiwu.me - njs.git/commitdiff
Interactive shell: quiet mode.
authorDmitry Volyntsev <xeioex@nginx.com>
Wed, 21 Nov 2018 13:45:10 +0000 (16:45 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Wed, 21 Nov 2018 13:45:10 +0000 (16:45 +0300)
njs/njs_shell.c
njs/test/njs_expect_test.exp

index 215a15d07984a8b3ad483e0835c1ee241017015c..7bd5678cb3688e1e90c7906f0e26d7466e2bbf2e 100644 (file)
@@ -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"
         "  <filename> | -  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.<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(">> ");
index c04af8a4d0f04ab5d7a1b50e75849fe86100b0b2..5ca680291ad82d7c4c1e419c4717d56e0f2ee6a3 100644 (file)
@@ -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+"