@optique/core 1.0.0-dev.1536 → 1.0.0-dev.1547

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/validate.cjs CHANGED
@@ -112,19 +112,30 @@ function validateMetaNameCollisions(userNames, metaEntries) {
112
112
  }
113
113
  }
114
114
  }
115
- for (const [kind, label, names, prefixMatch] of metaEntries) {
116
- const optionNames = kind === "command" ? userNames.leadingOptions : userNames.allOptions;
117
- const commandNames = kind === "command" ? userNames.leadingCommands : userNames.allCommands;
118
- for (const name of names) {
119
- if (optionNames.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
120
- if (commandNames.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
121
- const literalNames = kind === "command" ? userNames.leadingLiterals : userNames.allLiterals;
122
- if (literalNames.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
123
- if (prefixMatch) {
124
- const prefix = name + "=";
125
- for (const userName of optionNames) if (userName.startsWith(prefix)) throw new TypeError(`User-defined option "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
126
- for (const userName of commandNames) if (userName.startsWith(prefix)) throw new TypeError(`User-defined command "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
127
- for (const literal of literalNames) if (literal.startsWith(prefix)) throw new TypeError(`Literal value "${literal}" conflicts with the built-in ${label} (prefix "${prefix}").`);
115
+ for (const [kind, label, names, prefixMatch] of metaEntries) for (const name of names) {
116
+ if (kind === "command") {
117
+ if (userNames.leadingNames.has(name)) if (userNames.allOptions.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
118
+ else if (userNames.allCommands.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
119
+ else if (userNames.allLiterals.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
120
+ else throw new TypeError(`User-defined name "${name}" conflicts with the built-in ${label}.`);
121
+ } else {
122
+ if (userNames.allOptions.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
123
+ if (userNames.allCommands.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
124
+ if (userNames.allLiterals.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
125
+ }
126
+ if (prefixMatch) {
127
+ const prefix = name + "=";
128
+ const checkSets = kind === "command" ? [userNames.leadingNames] : [
129
+ userNames.allOptions,
130
+ userNames.allCommands,
131
+ userNames.allLiterals
132
+ ];
133
+ for (const nameSet of checkSets) for (const userName of nameSet) {
134
+ if (!userName.startsWith(prefix)) continue;
135
+ if (userNames.allOptions.has(userName)) throw new TypeError(`User-defined option "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
136
+ else if (userNames.allCommands.has(userName)) throw new TypeError(`User-defined command "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
137
+ else if (userNames.allLiterals.has(userName)) throw new TypeError(`Literal value "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
138
+ else throw new TypeError(`User-defined name "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
128
139
  }
129
140
  }
130
141
  }
package/dist/validate.js CHANGED
@@ -111,19 +111,30 @@ function validateMetaNameCollisions(userNames, metaEntries) {
111
111
  }
112
112
  }
113
113
  }
114
- for (const [kind, label, names, prefixMatch] of metaEntries) {
115
- const optionNames = kind === "command" ? userNames.leadingOptions : userNames.allOptions;
116
- const commandNames = kind === "command" ? userNames.leadingCommands : userNames.allCommands;
117
- for (const name of names) {
118
- if (optionNames.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
119
- if (commandNames.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
120
- const literalNames = kind === "command" ? userNames.leadingLiterals : userNames.allLiterals;
121
- if (literalNames.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
122
- if (prefixMatch) {
123
- const prefix = name + "=";
124
- for (const userName of optionNames) if (userName.startsWith(prefix)) throw new TypeError(`User-defined option "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
125
- for (const userName of commandNames) if (userName.startsWith(prefix)) throw new TypeError(`User-defined command "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
126
- for (const literal of literalNames) if (literal.startsWith(prefix)) throw new TypeError(`Literal value "${literal}" conflicts with the built-in ${label} (prefix "${prefix}").`);
114
+ for (const [kind, label, names, prefixMatch] of metaEntries) for (const name of names) {
115
+ if (kind === "command") {
116
+ if (userNames.leadingNames.has(name)) if (userNames.allOptions.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
117
+ else if (userNames.allCommands.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
118
+ else if (userNames.allLiterals.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
119
+ else throw new TypeError(`User-defined name "${name}" conflicts with the built-in ${label}.`);
120
+ } else {
121
+ if (userNames.allOptions.has(name)) throw new TypeError(`User-defined option "${name}" conflicts with the built-in ${label}.`);
122
+ if (userNames.allCommands.has(name)) throw new TypeError(`User-defined command "${name}" conflicts with the built-in ${label}.`);
123
+ if (userNames.allLiterals.has(name)) throw new TypeError(`Literal value "${name}" conflicts with the built-in ${label}.`);
124
+ }
125
+ if (prefixMatch) {
126
+ const prefix = name + "=";
127
+ const checkSets = kind === "command" ? [userNames.leadingNames] : [
128
+ userNames.allOptions,
129
+ userNames.allCommands,
130
+ userNames.allLiterals
131
+ ];
132
+ for (const nameSet of checkSets) for (const userName of nameSet) {
133
+ if (!userName.startsWith(prefix)) continue;
134
+ if (userNames.allOptions.has(userName)) throw new TypeError(`User-defined option "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
135
+ else if (userNames.allCommands.has(userName)) throw new TypeError(`User-defined command "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
136
+ else if (userNames.allLiterals.has(userName)) throw new TypeError(`Literal value "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
137
+ else throw new TypeError(`User-defined name "${userName}" conflicts with the built-in ${label} (prefix "${prefix}").`);
127
138
  }
128
139
  }
129
140
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1536+1f9feab6",
3
+ "version": "1.0.0-dev.1547+bde3f632",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",