@optique/core 1.0.0-dev.1553 → 1.0.0-dev.1555
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 +1 -0
- package/dist/facade.d.cts +7 -5
- package/dist/facade.d.ts +7 -5
- package/dist/facade.js +2 -1
- package/dist/program.cjs +4 -0
- package/dist/program.d.cts +2 -0
- package/dist/program.d.ts +2 -0
- package/dist/program.js +5 -0
- package/package.json +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -563,6 +563,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
563
563
|
args = argsOrOptions;
|
|
564
564
|
options = optionsParam ?? {};
|
|
565
565
|
}
|
|
566
|
+
require_validate.validateProgramName(programName);
|
|
566
567
|
const { colors, maxWidth, showDefault, showChoices, sectionOrder, aboveError = "usage", onError = () => {
|
|
567
568
|
throw new RunParserError("Failed to parse command line arguments.");
|
|
568
569
|
}, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
|
package/dist/facade.d.cts
CHANGED
|
@@ -272,11 +272,13 @@ interface RunOptions<THelp, TError> {
|
|
|
272
272
|
* @param options Configuration options for output formatting and callbacks.
|
|
273
273
|
* @returns The parsed result value, or the return value of `onHelp`/`onError`
|
|
274
274
|
* callbacks.
|
|
275
|
-
* @throws {TypeError} If `
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
275
|
+
* @throws {TypeError} If `programName` (or `program.metadata.name`) is not
|
|
276
|
+
* a string, is empty, is whitespace-only, or contains control
|
|
277
|
+
* characters. Also thrown if `options.version.value` is not a
|
|
278
|
+
* non-empty string without ASCII control characters, or if any
|
|
279
|
+
* meta command/option name is empty, whitespace-only, contains
|
|
280
|
+
* whitespace or control characters, or (for option names) lacks a
|
|
281
|
+
* valid prefix (`--`, `-`, `/`, or `+`).
|
|
280
282
|
* @throws {RunParserError} When parsing fails and no `onError` callback is
|
|
281
283
|
* provided.
|
|
282
284
|
* @since 0.10.0 Added support for {@link Program} objects.
|
package/dist/facade.d.ts
CHANGED
|
@@ -272,11 +272,13 @@ interface RunOptions<THelp, TError> {
|
|
|
272
272
|
* @param options Configuration options for output formatting and callbacks.
|
|
273
273
|
* @returns The parsed result value, or the return value of `onHelp`/`onError`
|
|
274
274
|
* callbacks.
|
|
275
|
-
* @throws {TypeError} If `
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
275
|
+
* @throws {TypeError} If `programName` (or `program.metadata.name`) is not
|
|
276
|
+
* a string, is empty, is whitespace-only, or contains control
|
|
277
|
+
* characters. Also thrown if `options.version.value` is not a
|
|
278
|
+
* non-empty string without ASCII control characters, or if any
|
|
279
|
+
* meta command/option name is empty, whitespace-only, contains
|
|
280
|
+
* whitespace or control characters, or (for option names) lacks a
|
|
281
|
+
* valid prefix (`--`, `-`, `/`, or `+`).
|
|
280
282
|
* @throws {RunParserError} When parsing fails and no `onError` callback is
|
|
281
283
|
* provided.
|
|
282
284
|
* @since 0.10.0 Added support for {@link Program} objects.
|
package/dist/facade.js
CHANGED
|
@@ -2,7 +2,7 @@ import { injectAnnotations } from "./annotations.js";
|
|
|
2
2
|
import { commandLine, formatMessage, lineBreak, message, optionName, text, value } from "./message.js";
|
|
3
3
|
import { bash, fish, nu, pwsh, zsh } from "./completion.js";
|
|
4
4
|
import { dispatchByMode } from "./mode-dispatch.js";
|
|
5
|
-
import { validateCommandNames, validateMetaNameCollisions, validateOptionNames } from "./validate.js";
|
|
5
|
+
import { validateCommandNames, validateMetaNameCollisions, validateOptionNames, validateProgramName } from "./validate.js";
|
|
6
6
|
import { extractCommandNames, extractLiteralValues, extractOptionNames, formatUsage } from "./usage.js";
|
|
7
7
|
import { formatDocPage } from "./doc.js";
|
|
8
8
|
import { group, longestMatch, object } from "./constructs.js";
|
|
@@ -563,6 +563,7 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
563
563
|
args = argsOrOptions;
|
|
564
564
|
options = optionsParam ?? {};
|
|
565
565
|
}
|
|
566
|
+
validateProgramName(programName);
|
|
566
567
|
const { colors, maxWidth, showDefault, showChoices, sectionOrder, aboveError = "usage", onError = () => {
|
|
567
568
|
throw new RunParserError("Failed to parse command line arguments.");
|
|
568
569
|
}, stderr = console.error, stdout = console.log, brief, description, examples, author, bugs, footer } = options;
|
package/dist/program.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_validate = require('./validate.cjs');
|
|
1
2
|
|
|
2
3
|
//#region src/program.ts
|
|
3
4
|
/**
|
|
@@ -11,6 +12,8 @@
|
|
|
11
12
|
* @template T - The type of value produced by the parser.
|
|
12
13
|
* @param program - The program definition with parser and metadata.
|
|
13
14
|
* @returns The same program object with inferred types.
|
|
15
|
+
* @throws {TypeError} If `program.metadata.name` is not a string, is empty,
|
|
16
|
+
* is whitespace-only, or contains control characters.
|
|
14
17
|
*
|
|
15
18
|
* @example
|
|
16
19
|
* ```typescript
|
|
@@ -37,6 +40,7 @@
|
|
|
37
40
|
* @since 1.0.0
|
|
38
41
|
*/
|
|
39
42
|
function defineProgram(program) {
|
|
43
|
+
require_validate.validateProgramName(program.metadata.name);
|
|
40
44
|
return program;
|
|
41
45
|
}
|
|
42
46
|
|
package/dist/program.d.cts
CHANGED
|
@@ -94,6 +94,8 @@ interface Program<M extends Mode, T> {
|
|
|
94
94
|
* @template T - The type of value produced by the parser.
|
|
95
95
|
* @param program - The program definition with parser and metadata.
|
|
96
96
|
* @returns The same program object with inferred types.
|
|
97
|
+
* @throws {TypeError} If `program.metadata.name` is not a string, is empty,
|
|
98
|
+
* is whitespace-only, or contains control characters.
|
|
97
99
|
*
|
|
98
100
|
* @example
|
|
99
101
|
* ```typescript
|
package/dist/program.d.ts
CHANGED
|
@@ -94,6 +94,8 @@ interface Program<M extends Mode, T> {
|
|
|
94
94
|
* @template T - The type of value produced by the parser.
|
|
95
95
|
* @param program - The program definition with parser and metadata.
|
|
96
96
|
* @returns The same program object with inferred types.
|
|
97
|
+
* @throws {TypeError} If `program.metadata.name` is not a string, is empty,
|
|
98
|
+
* is whitespace-only, or contains control characters.
|
|
97
99
|
*
|
|
98
100
|
* @example
|
|
99
101
|
* ```typescript
|
package/dist/program.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { validateProgramName } from "./validate.js";
|
|
2
|
+
|
|
1
3
|
//#region src/program.ts
|
|
2
4
|
/**
|
|
3
5
|
* Defines a CLI program with a parser and metadata.
|
|
@@ -10,6 +12,8 @@
|
|
|
10
12
|
* @template T - The type of value produced by the parser.
|
|
11
13
|
* @param program - The program definition with parser and metadata.
|
|
12
14
|
* @returns The same program object with inferred types.
|
|
15
|
+
* @throws {TypeError} If `program.metadata.name` is not a string, is empty,
|
|
16
|
+
* is whitespace-only, or contains control characters.
|
|
13
17
|
*
|
|
14
18
|
* @example
|
|
15
19
|
* ```typescript
|
|
@@ -36,6 +40,7 @@
|
|
|
36
40
|
* @since 1.0.0
|
|
37
41
|
*/
|
|
38
42
|
function defineProgram(program) {
|
|
43
|
+
validateProgramName(program.metadata.name);
|
|
39
44
|
return program;
|
|
40
45
|
}
|
|
41
46
|
|