@optique/core 1.3.0-dev.2519 → 1.3.0-dev.2522
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 +2 -1
- package/dist/facade.d.cts +15 -4
- package/dist/facade.d.ts +15 -4
- package/dist/facade.js +2 -1
- package/package.json +2 -2
- package/skills/optique/SKILL.md +7 -7
package/dist/facade.cjs
CHANGED
|
@@ -1054,8 +1054,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1054
1054
|
sectionOrder,
|
|
1055
1055
|
showUsage
|
|
1056
1056
|
}));
|
|
1057
|
+
return onHelp(0, renderedDoc);
|
|
1057
1058
|
}
|
|
1058
|
-
|
|
1059
|
+
throw new RunParserError("Failed to generate help page.");
|
|
1059
1060
|
};
|
|
1060
1061
|
if (classified.commands.length > 0) {
|
|
1061
1062
|
let validationContext = {
|
package/dist/facade.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "./message.cjs";
|
|
2
2
|
import { HiddenVisibility, OptionName, Usage } from "./usage.cjs";
|
|
3
|
-
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.cjs";
|
|
3
|
+
import { DocPage, DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.cjs";
|
|
4
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./internal/parser.cjs";
|
|
5
5
|
import { ShellCompletion } from "./completion.cjs";
|
|
6
6
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.cjs";
|
|
@@ -180,8 +180,19 @@ interface RunOptions<THelp, TError> {
|
|
|
180
180
|
* @since 1.0.0
|
|
181
181
|
*/
|
|
182
182
|
readonly help?: {
|
|
183
|
-
/**
|
|
184
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Callback invoked after help output, with the exit code and the final
|
|
185
|
+
* page passed to {@link formatDocPage}. Treat the page as read-only.
|
|
186
|
+
* It includes runner-provided entries and root usage customization.
|
|
187
|
+
* Subcommand and meta-command help use the selected command's docs,
|
|
188
|
+
* with the run-level footer as a fallback. Formatting options remain
|
|
189
|
+
* separate from the page.
|
|
190
|
+
*
|
|
191
|
+
* Handlers may ignore either argument. Wrappers that invoke this
|
|
192
|
+
* callback themselves must forward both arguments.
|
|
193
|
+
* @since 1.3.0 Added the `page` parameter.
|
|
194
|
+
*/
|
|
195
|
+
readonly onShow?: (exitCode: number, page: DocPage) => THelp;
|
|
185
196
|
} & ({
|
|
186
197
|
readonly command: true | CommandSubConfig;
|
|
187
198
|
readonly option?: true | OptionSubConfig;
|
|
@@ -341,7 +352,7 @@ interface RunOptions<THelp, TError> {
|
|
|
341
352
|
* whitespace or control characters, or (for option names) lacks a
|
|
342
353
|
* valid prefix (`--`, `-`, `/`, or `+`).
|
|
343
354
|
* @throws {RunParserError} When parsing fails and no `onError` callback is
|
|
344
|
-
* provided.
|
|
355
|
+
* provided, or if the requested help page cannot be generated.
|
|
345
356
|
* @since 0.10.0 Added support for {@link Program} objects.
|
|
346
357
|
*/
|
|
347
358
|
declare function runParser<T, THelp = void, TError = never>(program: Program<"sync", T>, args: readonly string[], options?: RunOptions<THelp, TError>): T;
|
package/dist/facade.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Message } from "./message.js";
|
|
2
2
|
import { HiddenVisibility, OptionName, Usage } from "./usage.js";
|
|
3
|
-
import { DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.js";
|
|
3
|
+
import { DocPage, DocSection, ShowChoicesOptions, ShowDefaultOptions } from "./doc.js";
|
|
4
4
|
import { InferMode, InferValue, Mode, ModeValue, Parser } from "./internal/parser.js";
|
|
5
5
|
import { ShellCompletion } from "./completion.js";
|
|
6
6
|
import { ParserValuePlaceholder, SourceContext, SourceContextRequest } from "./context.js";
|
|
@@ -180,8 +180,19 @@ interface RunOptions<THelp, TError> {
|
|
|
180
180
|
* @since 1.0.0
|
|
181
181
|
*/
|
|
182
182
|
readonly help?: {
|
|
183
|
-
/**
|
|
184
|
-
|
|
183
|
+
/**
|
|
184
|
+
* Callback invoked after help output, with the exit code and the final
|
|
185
|
+
* page passed to {@link formatDocPage}. Treat the page as read-only.
|
|
186
|
+
* It includes runner-provided entries and root usage customization.
|
|
187
|
+
* Subcommand and meta-command help use the selected command's docs,
|
|
188
|
+
* with the run-level footer as a fallback. Formatting options remain
|
|
189
|
+
* separate from the page.
|
|
190
|
+
*
|
|
191
|
+
* Handlers may ignore either argument. Wrappers that invoke this
|
|
192
|
+
* callback themselves must forward both arguments.
|
|
193
|
+
* @since 1.3.0 Added the `page` parameter.
|
|
194
|
+
*/
|
|
195
|
+
readonly onShow?: (exitCode: number, page: DocPage) => THelp;
|
|
185
196
|
} & ({
|
|
186
197
|
readonly command: true | CommandSubConfig;
|
|
187
198
|
readonly option?: true | OptionSubConfig;
|
|
@@ -341,7 +352,7 @@ interface RunOptions<THelp, TError> {
|
|
|
341
352
|
* whitespace or control characters, or (for option names) lacks a
|
|
342
353
|
* valid prefix (`--`, `-`, `/`, or `+`).
|
|
343
354
|
* @throws {RunParserError} When parsing fails and no `onError` callback is
|
|
344
|
-
* provided.
|
|
355
|
+
* provided, or if the requested help page cannot be generated.
|
|
345
356
|
* @since 0.10.0 Added support for {@link Program} objects.
|
|
346
357
|
*/
|
|
347
358
|
declare function runParser<T, THelp = void, TError = never>(program: Program<"sync", T>, args: readonly string[], options?: RunOptions<THelp, TError>): T;
|
package/dist/facade.js
CHANGED
|
@@ -1054,8 +1054,9 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1054
1054
|
sectionOrder,
|
|
1055
1055
|
showUsage
|
|
1056
1056
|
}));
|
|
1057
|
+
return onHelp(0, renderedDoc);
|
|
1057
1058
|
}
|
|
1058
|
-
|
|
1059
|
+
throw new RunParserError("Failed to generate help page.");
|
|
1059
1060
|
};
|
|
1060
1061
|
if (classified.commands.length > 0) {
|
|
1061
1062
|
let validationContext = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.3.0-dev.
|
|
3
|
+
"version": "1.3.0-dev.2522",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
},
|
|
222
222
|
"sideEffects": false,
|
|
223
223
|
"devDependencies": {
|
|
224
|
-
"@optique/env": "1.3.0-dev.
|
|
224
|
+
"@optique/env": "1.3.0-dev.2522+939139d1",
|
|
225
225
|
"@types/node": "^24.0.0",
|
|
226
226
|
"fast-check": "^4.7.0",
|
|
227
227
|
"tsdown": "^0.13.0",
|
package/skills/optique/SKILL.md
CHANGED
|
@@ -11,19 +11,19 @@ description: >
|
|
|
11
11
|
license: MIT
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
If online, start at <https://optique.dev/llms.txt> for maintained docs. These
|
|
17
|
-
rules also cover common pitfalls when offline.
|
|
14
|
+
Start at <https://optique.dev/llms.txt> when online. These rules cover the
|
|
15
|
+
combinatorial parser model and common pitfalls offline.
|
|
18
16
|
|
|
19
17
|
|
|
20
18
|
Core rules
|
|
21
19
|
----------
|
|
22
20
|
|
|
23
21
|
- Use `run()` from *@optique/run* for applications; use `parse()` or
|
|
24
|
-
`runParser()` for embedded and custom runtimes.
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
`runParser()` for embedded and custom runtimes.
|
|
23
|
+
- With `runParser()`, `onError(exitCode, error)` supplies a structured
|
|
24
|
+
`Message`; `help.onShow(exitCode, page)` supplies the final `DocPage`. Both
|
|
25
|
+
follow output. Supply `stdout: () => {}` for custom help rendering. See
|
|
26
|
+
<https://optique.dev/concepts/runners.md#structured-help-callbacks>.
|
|
27
27
|
- In tests, use `parseArgs()`/`parseArgsSync()` from *@optique/testing/parser*
|
|
28
28
|
for parser results, `captureRun()` from *@optique/testing/run* for runner
|
|
29
29
|
output/exits, `captureProgramRun()` from *@optique/testing/discover* for
|