summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-08-23 22:07:13 +0200
committerAnna Henningsen <anna@addaleax.net>2018-09-01 00:13:23 +0200
commitc8880ea27645aec31ef9dd5687c57747f338d67f (patch)
tree6c0bae2ba0dc4377a8d111e2890563860e3c6acb /src
parente812be4a55915575fc1afce739848026a48b781e (diff)
downloadandroid-node-v8-c8880ea27645aec31ef9dd5687c57747f338d67f.tar.gz
android-node-v8-c8880ea27645aec31ef9dd5687c57747f338d67f.tar.bz2
android-node-v8-c8880ea27645aec31ef9dd5687c57747f338d67f.zip
cli: generate --help text in JS
Instead of having a custom, static, hand-written string that is being printed to stdout when `--help` is present, generate it in JS when requested. PR-URL: https://github.com/nodejs/node/pull/22490 Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc154
-rw-r--r--src/node_config.cc4
-rw-r--r--src/node_options.cc12
3 files changed, 14 insertions, 156 deletions
diff --git a/src/node.cc b/src/node.cc
index 1336cdecb6..acaab53c13 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -2348,155 +2348,6 @@ void LoadEnvironment(Environment* env) {
}
}
-static void PrintHelp() {
- printf("Usage: node [options] [ -e script | script.js | - ] [arguments]\n"
- " node inspect script.js [arguments]\n"
- "\n"
- "Options:\n"
- " - script read from stdin (default; \n"
- " interactive mode if a tty)\n"
- " -- indicate the end of node options\n"
- " --abort-on-uncaught-exception\n"
- " aborting instead of exiting causes a\n"
- " core file to be generated for analysis\n"
-#if HAVE_OPENSSL && NODE_FIPS_MODE
- " --enable-fips enable FIPS crypto at startup\n"
-#endif // NODE_FIPS_MODE && NODE_FIPS_MODE
- " --experimental-modules experimental ES Module support\n"
- " and caching modules\n"
- " --experimental-repl-await experimental await keyword support\n"
- " in REPL\n"
- " --experimental-vm-modules experimental ES Module support\n"
- " in vm module\n"
- " --experimental-worker experimental threaded Worker support\n"
-#if HAVE_OPENSSL && NODE_FIPS_MODE
- " --force-fips force FIPS crypto (cannot be disabled)\n"
-#endif // HAVE_OPENSSL && NODE_FIPS_MODE
-#if defined(NODE_HAVE_I18N_SUPPORT)
- " --icu-data-dir=dir set ICU data load path to dir\n"
- " (overrides NODE_ICU_DATA)\n"
-#if !defined(NODE_HAVE_SMALL_ICU)
- " note: linked-in ICU data is present\n"
-#endif
-#endif // defined(NODE_HAVE_I18N_SUPPORT)
-#if HAVE_INSPECTOR
- " --inspect-brk[=[host:]port]\n"
- " activate inspector on host:port\n"
- " and break at start of user script\n"
- " --inspect-port=[host:]port\n"
- " set host:port for inspector\n"
- " --inspect[=[host:]port] activate inspector on host:port\n"
- " (default: 127.0.0.1:9229)\n"
-#endif // HAVE_INSPECTOR
- " --loader=file (with --experimental-modules) use the \n"
- " specified file as a custom loader\n"
- " for ECMAScript Modules \n"
- " --napi-modules load N-API modules (no-op - option\n"
- " kept for compatibility)\n"
- " --no-deprecation silence deprecation warnings\n"
- " --no-force-async-hooks-checks\n"
- " disable checks for async_hooks\n"
- " --no-warnings silence all process warnings\n"
-#if HAVE_OPENSSL
- " --openssl-config=file load OpenSSL configuration from the\n"
- " specified file (overrides\n"
- " OPENSSL_CONF)\n"
-#endif // HAVE_OPENSSL
- " --pending-deprecation emit pending deprecation warnings\n"
- " --preserve-symlinks preserve symbolic links when resolving\n"
- " --preserve-symlinks-main preserve symbolic links when resolving\n"
- " the main module\n"
- " --prof generate V8 profiler output\n"
- " --prof-process process V8 profiler output generated\n"
- " using --prof\n"
- " --redirect-warnings=file\n"
- " write warnings to file instead of\n"
- " stderr\n"
- " --throw-deprecation throw an exception on deprecations\n"
- " --title=title the process title to use on start up\n"
-#if HAVE_OPENSSL
- " --tls-cipher-list=val use an alternative default TLS cipher "
- "list\n"
-#endif // HAVE_OPENSSL
- " --trace-deprecation show stack traces on deprecations\n"
- " --trace-event-categories comma separated list of trace event\n"
- " categories to record\n"
- " --trace-event-file-pattern Template string specifying the\n"
- " filepath for the trace-events data, it\n"
- " supports ${rotation} and ${pid}\n"
- " log-rotation id. %%2$u is the pid.\n"
- " --trace-events-enabled track trace events\n"
- " --trace-sync-io show stack trace when use of sync IO\n"
- " is detected after the first tick\n"
- " --trace-warnings show stack traces on process warnings\n"
- " --track-heap-objects track heap object allocations for heap "
- "snapshots\n"
-#if HAVE_OPENSSL
- " --use-bundled-ca use bundled CA store"
-#if !defined(NODE_OPENSSL_CERT_STORE)
- " (default)"
-#endif
- "\n"
- " --use-openssl-ca use OpenSSL's default CA store"
-#if defined(NODE_OPENSSL_CERT_STORE)
- " (default)"
-#endif
-#endif // HAVE_OPENSSL
- "\n"
- " --v8-options print v8 command line options\n"
- " --v8-pool-size=num set v8's thread pool size\n"
- " --zero-fill-buffers automatically zero-fill all newly "
- "allocated\n"
- " Buffer and SlowBuffer instances\n"
- " -c, --check syntax check script without executing\n"
- " -e, --eval script evaluate script\n"
- " -h, --help print node command line options\n"
- " -i, --interactive always enter the REPL even if stdin\n"
- " does not appear to be a terminal\n"
- " -p, --print evaluate script and print result\n"
- " -r, --require module to preload (option can be "
- "repeated)\n"
- " -v, --version print Node.js version\n"
- "\n"
- "Environment variables:\n"
- "NODE_DEBUG ','-separated list of core modules\n"
- " that should print debug information\n"
- "NODE_DEBUG_NATIVE ','-separated list of C++ core debug\n"
- " categories that should print debug\n"
- " output\n"
- "NODE_DISABLE_COLORS set to 1 to disable colors in the REPL\n"
- "NODE_EXTRA_CA_CERTS path to additional CA certificates\n"
- " file\n"
-#if defined(NODE_HAVE_I18N_SUPPORT)
- "NODE_ICU_DATA data path for ICU (Intl object) data\n"
-#if !defined(NODE_HAVE_SMALL_ICU)
- " (will extend linked-in data)\n"
-#endif
-#endif // defined(NODE_HAVE_I18N_SUPPORT)
- "NODE_NO_WARNINGS set to 1 to silence process warnings\n"
-#if !defined(NODE_WITHOUT_NODE_OPTIONS)
- "NODE_OPTIONS set CLI options in the environment\n"
- " via a space-separated list\n"
-#endif // !defined(NODE_WITHOUT_NODE_OPTIONS)
-#ifdef _WIN32
- "NODE_PATH ';'-separated list of directories\n"
-#else
- "NODE_PATH ':'-separated list of directories\n"
-#endif
- " prefixed to the module search path\n"
- "NODE_PENDING_DEPRECATION set to 1 to emit pending deprecation\n"
- " warnings\n"
- "NODE_PRESERVE_SYMLINKS set to 1 to preserve symbolic links\n"
- " when resolving and caching modules\n"
- "NODE_REDIRECT_WARNINGS write warnings to path instead of\n"
- " stderr\n"
- "NODE_REPL_HISTORY path to the persistent REPL history\n"
- " file\n"
- "OPENSSL_CONF load OpenSSL configuration from file\n"
- "\n"
- "Documentation can be found at https://nodejs.org/\n");
-}
-
static void StartInspector(Environment* env, const char* path,
std::shared_ptr<DebugOptions> debug_options) {
@@ -2772,11 +2623,6 @@ void ProcessArgv(std::vector<std::string>* args,
exit(0);
}
- if (per_process_opts->print_help) {
- PrintHelp();
- exit(0);
- }
-
if (per_process_opts->print_v8_help) {
V8::SetFlagsFromString("--help", 6);
exit(0);
diff --git a/src/node_config.cc b/src/node_config.cc
index c6e6211da2..080d855066 100644
--- a/src/node_config.cc
+++ b/src/node_config.cc
@@ -73,6 +73,10 @@ static void Initialize(Local<Object> target,
READONLY_BOOLEAN_PROPERTY("hasTracing");
#endif
+#if !defined(NODE_WITHOUT_NODE_OPTIONS)
+ READONLY_BOOLEAN_PROPERTY("hasNodeOptions");
+#endif
+
// TODO(addaleax): This seems to be an unused, private API. Remove it?
READONLY_STRING_PROPERTY(target, "icuDataDir",
per_process_opts->icu_data_dir);
diff --git a/src/node_options.cc b/src/node_options.cc
index 88fac6a01f..27e518d0f1 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -251,11 +251,19 @@ PerProcessOptionsParser::PerProcessOptionsParser() {
&PerProcessOptions::tls_cipher_list,
kAllowedInEnvironment);
AddOption("--use-openssl-ca",
- "use OpenSSL's default CA store",
+ "use OpenSSL's default CA store"
+#if defined(NODE_OPENSSL_CERT_STORE)
+ " (default)"
+#endif
+ ,
&PerProcessOptions::use_openssl_ca,
kAllowedInEnvironment);
AddOption("--use-bundled-ca",
- "use bundled CA store",
+ "use bundled CA store"
+#if !defined(NODE_OPENSSL_CERT_STORE)
+ " (default)"
+#endif
+ ,
&PerProcessOptions::use_bundled_ca,
kAllowedInEnvironment);
// Similar to [has_eval_string] above, except that the separation between