icore 1.0.11 → 1.0.12
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.
- package/dist/options.d.ts +2 -2
- package/dist/options.js +1 -1
- package/package.json +1 -1
- package/readme.md +4 -4
package/dist/options.d.ts
CHANGED
|
@@ -36,10 +36,10 @@ export type StringOption<TChoices extends readonly string[] = readonly string[]>
|
|
|
36
36
|
* Declarative boolean flag contract.
|
|
37
37
|
*
|
|
38
38
|
* Boolean options accept flag form and explicit `true` / `false` values unless
|
|
39
|
-
*
|
|
39
|
+
* flag syntax is enforced.
|
|
40
40
|
*/
|
|
41
41
|
export type BooleanOption = OptionBase<'boolean', boolean> & {
|
|
42
|
-
|
|
42
|
+
syntax?: 'flag';
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* Declarative number option contract.
|
package/dist/options.js
CHANGED
|
@@ -104,7 +104,7 @@ function parseStringOption(name, definition, value) {
|
|
|
104
104
|
return value;
|
|
105
105
|
}
|
|
106
106
|
function parseBooleanOption(name, definition, value) {
|
|
107
|
-
if (definition.
|
|
107
|
+
if (definition.syntax === 'flag') {
|
|
108
108
|
if (value === true) {
|
|
109
109
|
return true;
|
|
110
110
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -455,19 +455,19 @@ Invalid explicit values are rejected:
|
|
|
455
455
|
`--uppercase false` keeps `--uppercase` as `true` and leaves `false` as a positional
|
|
456
456
|
argument.
|
|
457
457
|
|
|
458
|
-
Use `
|
|
458
|
+
Use `syntax: 'flag'` when a boolean option should accept only flag form:
|
|
459
459
|
|
|
460
460
|
```ts
|
|
461
461
|
const schema = {
|
|
462
462
|
uppercase: {
|
|
463
463
|
type: 'boolean',
|
|
464
464
|
default: false,
|
|
465
|
-
|
|
465
|
+
syntax: 'flag'
|
|
466
466
|
}
|
|
467
467
|
} as const;
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
With `
|
|
470
|
+
With `syntax: 'flag'`, `--uppercase` is accepted, while `--uppercase=true`,
|
|
471
471
|
`--uppercase=false`, and `--no-uppercase` are rejected.
|
|
472
472
|
|
|
473
473
|
### `type: 'number'`
|
|
@@ -567,7 +567,7 @@ Attached short values such as `-nvalue` and grouped short booleans such as
|
|
|
567
567
|
compatibility.
|
|
568
568
|
|
|
569
569
|
Negated syntax such as `--no-cache` is interpreted as `cache: false` when
|
|
570
|
-
`cache` is a known boolean option without `
|
|
570
|
+
`cache` is a known boolean option without `syntax: 'flag'`. Unknown negated
|
|
571
571
|
options, negation for string or number options, and negation for flag-only
|
|
572
572
|
boolean options are rejected.
|
|
573
573
|
|