From 1bbe66f432591aea83555d27dd76c55fea040a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 13 Jun 2021 12:46:35 +0200 Subject: src: allow to negate boolean CLI flags This change allows all boolean flags to be negated using the `--no-` prefix. Flags that are `true` by default (for example `--deprecation`) are still documented as negations. With this change, it becomes possible to easily flip the default value of a boolean flag and to override the value of a flag passed in the NODE_OPTIONS environment variable. `process.allowedNodeEnvironmentFlags` contains both the negated and non-negated versions of boolean flags. Co-authored-by: Anna Henningsen PR-URL: https://github.com/nodejs/node/pull/39023 Reviewed-By: Franziska Hinkelmann Reviewed-By: Michael Dawson Reviewed-By: Ruben Bridgewater --- src/node_options.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/node_options.h') diff --git a/src/node_options.h b/src/node_options.h index a91dbd25978..d737c4f55ae 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -119,9 +119,9 @@ class EnvironmentOptions : public Options { int64_t heap_snapshot_near_heap_limit = 0; std::string heap_snapshot_signal; uint64_t max_http_header_size = 16 * 1024; - bool no_deprecation = false; - bool no_force_async_hooks_checks = false; - bool no_warnings = false; + bool deprecation = true; + bool force_async_hooks_checks = true; + bool warnings = true; bool force_context_aware = false; bool pending_deprecation = false; bool preserve_symlinks = false; @@ -193,7 +193,7 @@ class PerIsolateOptions : public Options { public: std::shared_ptr per_env { new EnvironmentOptions() }; bool track_heap_objects = false; - bool no_node_snapshot = false; + bool node_snapshot = true; bool report_uncaught_exception = false; bool report_on_signal = false; bool experimental_top_level_await = true; @@ -301,7 +301,8 @@ class OptionsParser { void AddOption(const char* name, const char* help_text, bool Options::* field, - OptionEnvvarSettings env_setting = kDisallowedInEnvironment); + OptionEnvvarSettings env_setting = kDisallowedInEnvironment, + bool default_is_true = false); void AddOption(const char* name, const char* help_text, uint64_t Options::* field, @@ -424,6 +425,7 @@ class OptionsParser { std::shared_ptr field; OptionEnvvarSettings env_setting; std::string help_text; + bool default_is_true = false; }; // An implied option is composed of the information on where to store a -- cgit v1.2.3