Skip to content

Commit

Permalink
fixup! src: allow to negate boolean CLI flags
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Jun 13, 2021
1 parent 785cbb2 commit 69a8fcd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ auto OptionsParser<Options>::Convert(
return OptionInfo{original.type,
Convert(original.field, get_child),
original.env_setting,
original.help_text};
original.help_text,
original.default_is_true};
}

template <typename Options>
Expand Down Expand Up @@ -402,6 +403,13 @@ void OptionsParser<Options>::Parse(
}

const OptionInfo& info = it->second;

// Some V8 options can be negated and they are validated by V8 later.
if (is_negation && info.type != kBoolean && info.type != kV8Option) {
errors->push_back(NegationImpliesBooleanError(arg));
break;
}

std::string value;
if (info.type != kBoolean && info.type != kNoOp && info.type != kV8Option) {
if (equals_index != std::string::npos) {
Expand All @@ -428,11 +436,6 @@ void OptionsParser<Options>::Parse(
}
}

// Some V8 options can be negated and they are validated by V8 later.
if (is_negation && info.type != kBoolean && info.type != kV8Option) {
errors->push_back(NegationImpliesBooleanError(arg));
}

switch (info.type) {
case kBoolean:
*Lookup<bool>(info.field, options) = !is_negation;
Expand Down

0 comments on commit 69a8fcd

Please sign in to comment.