@optique/core 1.4.0-dev.2748 → 1.4.0-dev.2749
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 +17 -0
- package/dist/facade.js +17 -0
- package/dist/internal/help-request.cjs +33 -0
- package/dist/internal/help-request.d.cts +20 -0
- package/dist/internal/help-request.d.ts +20 -0
- package/dist/internal/help-request.js +31 -0
- package/package.json +10 -2
- package/skills/optique/SKILL.md +1 -1
package/dist/facade.cjs
CHANGED
|
@@ -17,6 +17,7 @@ const require_command_alias = require('./internal/command-alias.cjs');
|
|
|
17
17
|
const require_phase2_seed = require('./phase2-seed.cjs');
|
|
18
18
|
const require_modifiers = require('./modifiers.cjs');
|
|
19
19
|
const require_constructs = require('./constructs.cjs');
|
|
20
|
+
const require_internal_help_request = require('./internal/help-request.cjs');
|
|
20
21
|
const require_valueparser = require('./valueparser.cjs');
|
|
21
22
|
const require_primitives = require('./primitives.cjs');
|
|
22
23
|
|
|
@@ -1145,6 +1146,20 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1145
1146
|
}
|
|
1146
1147
|
};
|
|
1147
1148
|
const parserMode = parser.mode;
|
|
1149
|
+
const helpRequest = require_internal_help_request.getHelpRequest(options);
|
|
1150
|
+
if (helpRequest != null) return require_mode_dispatch.dispatchByMode(parserMode, () => {
|
|
1151
|
+
const handled = handleResult({
|
|
1152
|
+
type: "help",
|
|
1153
|
+
commands: helpRequest,
|
|
1154
|
+
preferUserCommandDocs: true
|
|
1155
|
+
});
|
|
1156
|
+
if (handled instanceof Promise) throw new RunParserError("Synchronous parser returned async result.");
|
|
1157
|
+
return handled;
|
|
1158
|
+
}, async () => await handleResult({
|
|
1159
|
+
type: "help",
|
|
1160
|
+
commands: helpRequest,
|
|
1161
|
+
preferUserCommandDocs: true
|
|
1162
|
+
}));
|
|
1148
1163
|
return require_mode_dispatch.dispatchByMode(parserMode, () => {
|
|
1149
1164
|
const attempted = require_internal_parser.attemptParseSync(parser, args, {
|
|
1150
1165
|
mode: "complete",
|
|
@@ -1368,6 +1383,7 @@ function shouldProbeEarlyExit(options, needsTwoPhase) {
|
|
|
1368
1383
|
* handled without collecting source-context annotations first.
|
|
1369
1384
|
*/
|
|
1370
1385
|
function needsEarlyExitSync(parser, args, options) {
|
|
1386
|
+
if (require_internal_help_request.getHelpRequest(options) != null) return true;
|
|
1371
1387
|
const attempted = require_internal_parser.attemptParseSync(parser, args, { mode: "parse-only" });
|
|
1372
1388
|
if (attempted.kind === "success") return false;
|
|
1373
1389
|
return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
|
|
@@ -1376,6 +1392,7 @@ function needsEarlyExitSync(parser, args, options) {
|
|
|
1376
1392
|
* Async variant of {@link needsEarlyExitSync}.
|
|
1377
1393
|
*/
|
|
1378
1394
|
async function needsEarlyExitAsync(parser, args, options) {
|
|
1395
|
+
if (require_internal_help_request.getHelpRequest(options) != null) return true;
|
|
1379
1396
|
const attempted = await require_internal_parser.attemptParseAsync(parser, args, { mode: "parse-only" });
|
|
1380
1397
|
if (attempted.kind === "success") return false;
|
|
1381
1398
|
return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
|
package/dist/facade.js
CHANGED
|
@@ -17,6 +17,7 @@ import { allowDuplicateLeadingCommandNamesKey, hiddenCommandAliasesKey } from ".
|
|
|
17
17
|
import { completeOrExtractPhase2Seed } from "./phase2-seed.js";
|
|
18
18
|
import { multiple, optional, withDefault } from "./modifiers.js";
|
|
19
19
|
import { group, longestMatch, object } from "./constructs.js";
|
|
20
|
+
import { getHelpRequest } from "./internal/help-request.js";
|
|
20
21
|
import { string } from "./valueparser.js";
|
|
21
22
|
import { argument, command, constant, flag, option } from "./primitives.js";
|
|
22
23
|
|
|
@@ -1145,6 +1146,20 @@ function runParser(parserOrProgram, programNameOrArgs, argsOrOptions, optionsPar
|
|
|
1145
1146
|
}
|
|
1146
1147
|
};
|
|
1147
1148
|
const parserMode = parser.mode;
|
|
1149
|
+
const helpRequest = getHelpRequest(options);
|
|
1150
|
+
if (helpRequest != null) return dispatchByMode(parserMode, () => {
|
|
1151
|
+
const handled = handleResult({
|
|
1152
|
+
type: "help",
|
|
1153
|
+
commands: helpRequest,
|
|
1154
|
+
preferUserCommandDocs: true
|
|
1155
|
+
});
|
|
1156
|
+
if (handled instanceof Promise) throw new RunParserError("Synchronous parser returned async result.");
|
|
1157
|
+
return handled;
|
|
1158
|
+
}, async () => await handleResult({
|
|
1159
|
+
type: "help",
|
|
1160
|
+
commands: helpRequest,
|
|
1161
|
+
preferUserCommandDocs: true
|
|
1162
|
+
}));
|
|
1148
1163
|
return dispatchByMode(parserMode, () => {
|
|
1149
1164
|
const attempted = attemptParseSync(parser, args, {
|
|
1150
1165
|
mode: "complete",
|
|
@@ -1368,6 +1383,7 @@ function shouldProbeEarlyExit(options, needsTwoPhase) {
|
|
|
1368
1383
|
* handled without collecting source-context annotations first.
|
|
1369
1384
|
*/
|
|
1370
1385
|
function needsEarlyExitSync(parser, args, options) {
|
|
1386
|
+
if (getHelpRequest(options) != null) return true;
|
|
1371
1387
|
const attempted = attemptParseSync(parser, args, { mode: "parse-only" });
|
|
1372
1388
|
if (attempted.kind === "success") return false;
|
|
1373
1389
|
return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
|
|
@@ -1376,6 +1392,7 @@ function needsEarlyExitSync(parser, args, options) {
|
|
|
1376
1392
|
* Async variant of {@link needsEarlyExitSync}.
|
|
1377
1393
|
*/
|
|
1378
1394
|
async function needsEarlyExitAsync(parser, args, options) {
|
|
1395
|
+
if (getHelpRequest(options) != null) return true;
|
|
1379
1396
|
const attempted = await attemptParseAsync(parser, args, { mode: "parse-only" });
|
|
1380
1397
|
if (attempted.kind === "success") return false;
|
|
1381
1398
|
return isMetaEarlyExit(classifyEarlyExitFailure(attempted, options));
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/internal/help-request.ts
|
|
3
|
+
/** Internal help request bridge; not a stable extension API. @module */
|
|
4
|
+
const helpRequestKey = Symbol.for("@optique/core/internal/help-request");
|
|
5
|
+
/**
|
|
6
|
+
* Copies options with a help target independent of help entry-point names.
|
|
7
|
+
* @param options The runner options to copy.
|
|
8
|
+
* @param commands The canonical command path to display.
|
|
9
|
+
* @returns Options carrying the internal request through transparent spreads.
|
|
10
|
+
* @internal
|
|
11
|
+
* @since 1.4.0
|
|
12
|
+
*/
|
|
13
|
+
function withHelpRequest(options, commands) {
|
|
14
|
+
return {
|
|
15
|
+
...options,
|
|
16
|
+
[helpRequestKey]: [...commands]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reads an internal help target, including the empty root path.
|
|
21
|
+
* @param options The runner options.
|
|
22
|
+
* @returns The requested path, or undefined when no request exists.
|
|
23
|
+
* @internal
|
|
24
|
+
* @since 1.4.0
|
|
25
|
+
*/
|
|
26
|
+
function getHelpRequest(options) {
|
|
27
|
+
const value = Reflect.get(options, helpRequestKey);
|
|
28
|
+
return Array.isArray(value) && value.every((part) => typeof part === "string") ? value : void 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.getHelpRequest = getHelpRequest;
|
|
33
|
+
exports.withHelpRequest = withHelpRequest;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/internal/help-request.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copies options with a help target independent of help entry-point names.
|
|
4
|
+
* @param options The runner options to copy.
|
|
5
|
+
* @param commands The canonical command path to display.
|
|
6
|
+
* @returns Options carrying the internal request through transparent spreads.
|
|
7
|
+
* @internal
|
|
8
|
+
* @since 1.4.0
|
|
9
|
+
*/
|
|
10
|
+
declare function withHelpRequest<T extends object>(options: T, commands: readonly string[]): T;
|
|
11
|
+
/**
|
|
12
|
+
* Reads an internal help target, including the empty root path.
|
|
13
|
+
* @param options The runner options.
|
|
14
|
+
* @returns The requested path, or undefined when no request exists.
|
|
15
|
+
* @internal
|
|
16
|
+
* @since 1.4.0
|
|
17
|
+
*/
|
|
18
|
+
declare function getHelpRequest(options: object): readonly string[] | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getHelpRequest, withHelpRequest };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/internal/help-request.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Copies options with a help target independent of help entry-point names.
|
|
4
|
+
* @param options The runner options to copy.
|
|
5
|
+
* @param commands The canonical command path to display.
|
|
6
|
+
* @returns Options carrying the internal request through transparent spreads.
|
|
7
|
+
* @internal
|
|
8
|
+
* @since 1.4.0
|
|
9
|
+
*/
|
|
10
|
+
declare function withHelpRequest<T extends object>(options: T, commands: readonly string[]): T;
|
|
11
|
+
/**
|
|
12
|
+
* Reads an internal help target, including the empty root path.
|
|
13
|
+
* @param options The runner options.
|
|
14
|
+
* @returns The requested path, or undefined when no request exists.
|
|
15
|
+
* @internal
|
|
16
|
+
* @since 1.4.0
|
|
17
|
+
*/
|
|
18
|
+
declare function getHelpRequest(options: object): readonly string[] | undefined;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { getHelpRequest, withHelpRequest };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/internal/help-request.ts
|
|
2
|
+
/** Internal help request bridge; not a stable extension API. @module */
|
|
3
|
+
const helpRequestKey = Symbol.for("@optique/core/internal/help-request");
|
|
4
|
+
/**
|
|
5
|
+
* Copies options with a help target independent of help entry-point names.
|
|
6
|
+
* @param options The runner options to copy.
|
|
7
|
+
* @param commands The canonical command path to display.
|
|
8
|
+
* @returns Options carrying the internal request through transparent spreads.
|
|
9
|
+
* @internal
|
|
10
|
+
* @since 1.4.0
|
|
11
|
+
*/
|
|
12
|
+
function withHelpRequest(options, commands) {
|
|
13
|
+
return {
|
|
14
|
+
...options,
|
|
15
|
+
[helpRequestKey]: [...commands]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads an internal help target, including the empty root path.
|
|
20
|
+
* @param options The runner options.
|
|
21
|
+
* @returns The requested path, or undefined when no request exists.
|
|
22
|
+
* @internal
|
|
23
|
+
* @since 1.4.0
|
|
24
|
+
*/
|
|
25
|
+
function getHelpRequest(options) {
|
|
26
|
+
const value = Reflect.get(options, helpRequestKey);
|
|
27
|
+
return Array.isArray(value) && value.every((part) => typeof part === "string") ? value : void 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { getHelpRequest, withHelpRequest };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/core",
|
|
3
|
-
"version": "1.4.0-dev.
|
|
3
|
+
"version": "1.4.0-dev.2749",
|
|
4
4
|
"description": "Type-safe combinatorial command-line interface parser",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -243,6 +243,14 @@
|
|
|
243
243
|
},
|
|
244
244
|
"import": "./dist/internal/command-doc-policy.js",
|
|
245
245
|
"require": "./dist/internal/command-doc-policy.cjs"
|
|
246
|
+
},
|
|
247
|
+
"./internal/help-request": {
|
|
248
|
+
"types": {
|
|
249
|
+
"import": "./dist/internal/help-request.d.ts",
|
|
250
|
+
"require": "./dist/internal/help-request.d.cts"
|
|
251
|
+
},
|
|
252
|
+
"import": "./dist/internal/help-request.js",
|
|
253
|
+
"require": "./dist/internal/help-request.cjs"
|
|
246
254
|
}
|
|
247
255
|
},
|
|
248
256
|
"imports": {
|
|
@@ -253,7 +261,7 @@
|
|
|
253
261
|
},
|
|
254
262
|
"sideEffects": false,
|
|
255
263
|
"devDependencies": {
|
|
256
|
-
"@optique/env": "1.4.0-dev.
|
|
264
|
+
"@optique/env": "1.4.0-dev.2749+6d558083",
|
|
257
265
|
"@types/node": "^24.0.0",
|
|
258
266
|
"fast-check": "^4.7.0",
|
|
259
267
|
"tsdown": "^0.13.0",
|
package/skills/optique/SKILL.md
CHANGED
|
@@ -295,5 +295,5 @@ Integration packages
|
|
|
295
295
|
| `@optique/git` | Async Git reference validation | <https://optique.dev/integrations/git.md> |
|
|
296
296
|
| `@optique/logtape` | LogTape levels and formatter/output options | <https://optique.dev/integrations/logtape.md> |
|
|
297
297
|
| `@optique/man` | Man page generation | <https://optique.dev/concepts/man.md> |
|
|
298
|
-
| `@optique/discover` |
|
|
298
|
+
| `@optique/discover` | Command discovery; opt-in `help.bareGroup` | <https://optique.dev/concepts/discover.md> |
|
|
299
299
|
| `@optique/testing` | Layered CLI testing at a chosen boundary | <https://optique.dev/concepts/testing.md> |
|