@optique/core 1.0.0-dev.1502 → 1.0.0-dev.1510

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.
@@ -968,8 +968,11 @@ async function* suggestCommandAsync(context, prefix, name, parser, options) {
968
968
  * a description for documentation.
969
969
  * @returns A {@link Parser} that matches the command name and delegates
970
970
  * to the inner parser for the remaining arguments.
971
+ * @throws {TypeError} If `name` is empty, whitespace-only, contains
972
+ * embedded whitespace, or contains control characters.
971
973
  */
972
974
  function command(name, parser, options = {}) {
975
+ require_validate.validateCommandNames([name], "Command");
973
976
  const isAsync = parser.$mode === "async";
974
977
  const result = {
975
978
  [Symbol.for("@optique/core/commandParser")]: true,
@@ -396,6 +396,8 @@ type CommandState<TState> = undefined | ["matched", string] | ["parsing", TState
396
396
  * a description for documentation.
397
397
  * @returns A {@link Parser} that matches the command name and delegates
398
398
  * to the inner parser for the remaining arguments.
399
+ * @throws {TypeError} If `name` is empty, whitespace-only, contains
400
+ * embedded whitespace, or contains control characters.
399
401
  */
400
402
  declare function command<M extends Mode, T, TState>(name: string, parser: Parser<M, T, TState>, options?: CommandOptions): Parser<M, T, CommandState<TState>>;
401
403
  /**
@@ -396,6 +396,8 @@ type CommandState<TState> = undefined | ["matched", string] | ["parsing", TState
396
396
  * a description for documentation.
397
397
  * @returns A {@link Parser} that matches the command name and delegates
398
398
  * to the inner parser for the remaining arguments.
399
+ * @throws {TypeError} If `name` is empty, whitespace-only, contains
400
+ * embedded whitespace, or contains control characters.
399
401
  */
400
402
  declare function command<M extends Mode, T, TState>(name: string, parser: Parser<M, T, TState>, options?: CommandOptions): Parser<M, T, CommandState<TState>>;
401
403
  /**
@@ -2,7 +2,7 @@ import { annotateFreshArray, getAnnotations } from "./annotations.js";
2
2
  import { message, metavar, optionName, optionNames, text, valueSet } from "./message.js";
3
3
  import { createDeferredParseState, createDependencySourceState, createPendingDependencySourceState, dependencyId, getDefaultValuesFunction, getDependencyIds, isDeferredParseState, isDependencySource, isDependencySourceState, isDerivedValueParser, isPendingDependencySourceState, suggestWithDependency } from "./dependency.js";
4
4
  import { dispatchIterableByMode } from "./mode-dispatch.js";
5
- import { validateOptionNames } from "./validate.js";
5
+ import { validateCommandNames, validateOptionNames } from "./validate.js";
6
6
  import { extractOptionNames, isDocHidden, isSuggestionHidden } from "./usage.js";
7
7
  import { DEFAULT_FIND_SIMILAR_OPTIONS, createErrorWithSuggestions, createSuggestionMessage, findSimilar } from "./suggestion.js";
8
8
  import { extractLeadingCommandNames } from "./usage-internals.js";
@@ -968,8 +968,11 @@ async function* suggestCommandAsync(context, prefix, name, parser, options) {
968
968
  * a description for documentation.
969
969
  * @returns A {@link Parser} that matches the command name and delegates
970
970
  * to the inner parser for the remaining arguments.
971
+ * @throws {TypeError} If `name` is empty, whitespace-only, contains
972
+ * embedded whitespace, or contains control characters.
971
973
  */
972
974
  function command(name, parser, options = {}) {
975
+ validateCommandNames([name], "Command");
973
976
  const isAsync = parser.$mode === "async";
974
977
  const result = {
975
978
  [Symbol.for("@optique/core/commandParser")]: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1502+fda779c7",
3
+ "version": "1.0.0-dev.1510+f054ad59",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",