@optique/core 1.0.0-dev.1228 → 1.0.0-dev.1236

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/facade.cjs CHANGED
@@ -1104,9 +1104,12 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1104
1104
  * @param args The command-line arguments to parse.
1105
1105
  * @param options Configuration options for customizing behavior.
1106
1106
  * @returns The parsed result if successful.
1107
+ * @throws {TypeError} If an async parser is passed at runtime. Use
1108
+ * {@link runParser} or {@link runParserAsync} for async parsers.
1107
1109
  * @since 0.9.0
1108
1110
  */
1109
1111
  function runParserSync(parser, programName, args, options) {
1112
+ if (parser.$mode !== "sync") throw new TypeError("Cannot use an async parser with runParserSync(). Use runParser() or runParserAsync() instead.");
1110
1113
  return runParser(parser, programName, args, options);
1111
1114
  }
1112
1115
  /**
@@ -1465,11 +1468,14 @@ async function runWith(parser, programName, contexts, options) {
1465
1468
  * @param contexts Source contexts to use (priority: earlier overrides later).
1466
1469
  * @param options Run options including args, help, version, etc.
1467
1470
  * @returns The parsed result.
1468
- * @throws Error if any context returns a Promise or if a context's
1471
+ * @throws {TypeError} If an async parser is passed at runtime. Use
1472
+ * {@link runWith} or {@link runWithAsync} for async parsers.
1473
+ * @throws {Error} If any context returns a Promise or if a context's
1469
1474
  * `[Symbol.asyncDispose]` returns a Promise.
1470
1475
  * @since 0.10.0
1471
1476
  */
1472
1477
  function runWithSync(parser, programName, contexts, options) {
1478
+ if (parser.$mode !== "sync") throw new TypeError("Cannot use an async parser with runWithSync(). Use runWith() or runWithAsync() instead.");
1473
1479
  const args = options?.args ?? [];
1474
1480
  if (needsEarlyExit(args, options)) return runParser(parser, programName, args, options);
1475
1481
  if (contexts.length === 0) return runParser(parser, programName, args, options);
package/dist/facade.d.cts CHANGED
@@ -301,6 +301,8 @@ declare function runParser<TParser extends Parser<Mode, unknown, unknown>, THelp
301
301
  * @param args The command-line arguments to parse.
302
302
  * @param options Configuration options for customizing behavior.
303
303
  * @returns The parsed result if successful.
304
+ * @throws {TypeError} If an async parser is passed at runtime. Use
305
+ * {@link runParser} or {@link runParserAsync} for async parsers.
304
306
  * @since 0.9.0
305
307
  */
306
308
  declare function runParserSync<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
@@ -461,7 +463,9 @@ declare function runWith<TParser extends Parser<Mode, unknown, unknown>, TContex
461
463
  * @param contexts Source contexts to use (priority: earlier overrides later).
462
464
  * @param options Run options including args, help, version, etc.
463
465
  * @returns The parsed result.
464
- * @throws Error if any context returns a Promise or if a context's
466
+ * @throws {TypeError} If an async parser is passed at runtime. Use
467
+ * {@link runWith} or {@link runWithAsync} for async parsers.
468
+ * @throws {Error} If any context returns a Promise or if a context's
465
469
  * `[Symbol.asyncDispose]` returns a Promise.
466
470
  * @since 0.10.0
467
471
  */
package/dist/facade.d.ts CHANGED
@@ -301,6 +301,8 @@ declare function runParser<TParser extends Parser<Mode, unknown, unknown>, THelp
301
301
  * @param args The command-line arguments to parse.
302
302
  * @param options Configuration options for customizing behavior.
303
303
  * @returns The parsed result if successful.
304
+ * @throws {TypeError} If an async parser is passed at runtime. Use
305
+ * {@link runParser} or {@link runParserAsync} for async parsers.
304
306
  * @since 0.9.0
305
307
  */
306
308
  declare function runParserSync<TParser extends Parser<"sync", unknown, unknown>, THelp = void, TError = never>(parser: TParser, programName: string, args: readonly string[], options?: RunOptions<THelp, TError>): InferValue<TParser>;
@@ -461,7 +463,9 @@ declare function runWith<TParser extends Parser<Mode, unknown, unknown>, TContex
461
463
  * @param contexts Source contexts to use (priority: earlier overrides later).
462
464
  * @param options Run options including args, help, version, etc.
463
465
  * @returns The parsed result.
464
- * @throws Error if any context returns a Promise or if a context's
466
+ * @throws {TypeError} If an async parser is passed at runtime. Use
467
+ * {@link runWith} or {@link runWithAsync} for async parsers.
468
+ * @throws {Error} If any context returns a Promise or if a context's
465
469
  * `[Symbol.asyncDispose]` returns a Promise.
466
470
  * @since 0.10.0
467
471
  */
package/dist/facade.js CHANGED
@@ -1104,9 +1104,12 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
1104
1104
  * @param args The command-line arguments to parse.
1105
1105
  * @param options Configuration options for customizing behavior.
1106
1106
  * @returns The parsed result if successful.
1107
+ * @throws {TypeError} If an async parser is passed at runtime. Use
1108
+ * {@link runParser} or {@link runParserAsync} for async parsers.
1107
1109
  * @since 0.9.0
1108
1110
  */
1109
1111
  function runParserSync(parser, programName, args, options) {
1112
+ if (parser.$mode !== "sync") throw new TypeError("Cannot use an async parser with runParserSync(). Use runParser() or runParserAsync() instead.");
1110
1113
  return runParser(parser, programName, args, options);
1111
1114
  }
1112
1115
  /**
@@ -1465,11 +1468,14 @@ async function runWith(parser, programName, contexts, options) {
1465
1468
  * @param contexts Source contexts to use (priority: earlier overrides later).
1466
1469
  * @param options Run options including args, help, version, etc.
1467
1470
  * @returns The parsed result.
1468
- * @throws Error if any context returns a Promise or if a context's
1471
+ * @throws {TypeError} If an async parser is passed at runtime. Use
1472
+ * {@link runWith} or {@link runWithAsync} for async parsers.
1473
+ * @throws {Error} If any context returns a Promise or if a context's
1469
1474
  * `[Symbol.asyncDispose]` returns a Promise.
1470
1475
  * @since 0.10.0
1471
1476
  */
1472
1477
  function runWithSync(parser, programName, contexts, options) {
1478
+ if (parser.$mode !== "sync") throw new TypeError("Cannot use an async parser with runWithSync(). Use runWith() or runWithAsync() instead.");
1473
1479
  const args = options?.args ?? [];
1474
1480
  if (needsEarlyExit(args, options)) return runParser(parser, programName, args, options);
1475
1481
  if (contexts.length === 0) return runParser(parser, programName, args, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optique/core",
3
- "version": "1.0.0-dev.1228+2971180c",
3
+ "version": "1.0.0-dev.1236+3ee9891d",
4
4
  "description": "Type-safe combinatorial command-line interface parser",
5
5
  "keywords": [
6
6
  "CLI",