@oclif/core 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -75,6 +75,7 @@ const validateOptions = (flag, input) => {
75
75
  throw new errors_1.FlagInvalidOptionError(flag, input);
76
76
  return input;
77
77
  };
78
+ const NEGATION = '--no-';
78
79
  class Parser {
79
80
  input;
80
81
  argv;
@@ -299,9 +300,16 @@ class Parser {
299
300
  if (tokenLength) {
300
301
  // boolean
301
302
  if (fws.inputFlag.flag.type === 'boolean' && (0, util_1.last)(fws.tokens)?.input) {
303
+ const doesNotContainNegation = (i) => {
304
+ const possibleNegations = [i.inputFlag.name, ...(i.inputFlag.flag.aliases ?? [])].map((n) => `${NEGATION}${n}`);
305
+ const input = (0, util_1.last)(i.tokens)?.input;
306
+ if (!input)
307
+ return true;
308
+ return !possibleNegations.includes(input);
309
+ };
302
310
  return {
303
311
  ...fws,
304
- valueFunction: async (i) => parseFlagOrThrowError((0, util_1.last)(i.tokens)?.input !== `--no-${i.inputFlag.name}`, i.inputFlag.flag, this.context, (0, util_1.last)(i.tokens)),
312
+ valueFunction: async (i) => parseFlagOrThrowError(doesNotContainNegation(i), i.inputFlag.flag, this.context, (0, util_1.last)(i.tokens)),
305
313
  };
306
314
  }
307
315
  // multiple with custom delimiter
@@ -455,10 +463,14 @@ class Parser {
455
463
  if (this.flagAliases[name]) {
456
464
  return this.flagAliases[name].name;
457
465
  }
458
- if (arg.startsWith('--no-')) {
459
- const flag = this.booleanFlags[arg.slice(5)];
466
+ if (arg.startsWith(NEGATION)) {
467
+ const flag = this.booleanFlags[arg.slice(NEGATION.length)];
460
468
  if (flag && flag.allowNo)
461
469
  return flag.name;
470
+ const flagAlias = this.flagAliases[arg.slice(NEGATION.length)];
471
+ if (flagAlias && flagAlias.type === 'boolean' && flagAlias.allowNo) {
472
+ return flagAlias.name;
473
+ }
462
474
  }
463
475
  }
464
476
  findShortFlag([_, char]) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.6.0",
4
+ "version": "4.7.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {