sim 2.2.22-preview.264.1 → 2.2.22-preview.266.1
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/index.js +110 -35
- package/dist/runtime/build.d.ts +7 -0
- package/dist/runtime.js +110 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21354,6 +21354,27 @@ async function localFile(path, override) {
|
|
|
21354
21354
|
}
|
|
21355
21355
|
|
|
21356
21356
|
// src/runtime/request.ts
|
|
21357
|
+
var BODY_VARIANT_EXAMPLES = {
|
|
21358
|
+
array: `'[{"key":"value"}]'`,
|
|
21359
|
+
object: `'{"key":"value"}'`
|
|
21360
|
+
};
|
|
21361
|
+
function jsonShape(value) {
|
|
21362
|
+
if (Array.isArray(value))
|
|
21363
|
+
return "array";
|
|
21364
|
+
if (isRecordLike(value))
|
|
21365
|
+
return "object";
|
|
21366
|
+
return;
|
|
21367
|
+
}
|
|
21368
|
+
function bodyVariantShapeError(variant, parsed, shape, variants) {
|
|
21369
|
+
const flag = `--${variant.name}`;
|
|
21370
|
+
const got = shape ? `a JSON ${shape}` : parsed === null ? "null" : `a JSON ${typeof parsed}`;
|
|
21371
|
+
const base = `${flag} must be a JSON ${variant.kind}, e.g. ${flag} ${BODY_VARIANT_EXAMPLES[variant.kind]}; got ${got}.`;
|
|
21372
|
+
if (variant.kind === "array" && isRecordLike(parsed) && Array.isArray(parsed[variant.property])) {
|
|
21373
|
+
return `${base} Pass the array under its "${variant.property}" key itself, not the object wrapping it.`;
|
|
21374
|
+
}
|
|
21375
|
+
const other = shape && variants.find((candidate) => candidate !== variant && candidate.kind === shape);
|
|
21376
|
+
return other ? `${base} For that shape use --${other.name}.` : base;
|
|
21377
|
+
}
|
|
21357
21378
|
var PROFILE_INJECTED_FIELD = "workspaceId";
|
|
21358
21379
|
function isProfileWorkspacePath(commandSpec, param) {
|
|
21359
21380
|
return commandSpec.profileWorkspacePath === true && param === PROFILE_INJECTED_FIELD;
|
|
@@ -21725,8 +21746,9 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
21725
21746
|
if (typeof raw !== "string")
|
|
21726
21747
|
throw new SimApiError(`--${variant.name} is required`, 0);
|
|
21727
21748
|
const parsed = await coerce(raw, { kind: variant.kind }, { json: true }, variant.name);
|
|
21728
|
-
|
|
21729
|
-
|
|
21749
|
+
const shape = jsonShape(parsed);
|
|
21750
|
+
if (shape !== variant.kind) {
|
|
21751
|
+
throw new SimApiError(bodyVariantShapeError(variant, parsed, shape, commandSpec.bodyVariants), 0);
|
|
21730
21752
|
}
|
|
21731
21753
|
return boundedRequest({
|
|
21732
21754
|
params,
|
|
@@ -22370,39 +22392,94 @@ function commandPath2(command) {
|
|
|
22370
22392
|
}
|
|
22371
22393
|
return names.join(" ");
|
|
22372
22394
|
}
|
|
22373
|
-
var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
|
|
22374
22395
|
function looksLikeAnId(token) {
|
|
22375
22396
|
return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
|
|
22376
22397
|
}
|
|
22377
|
-
function
|
|
22378
|
-
|
|
22379
|
-
|
|
22380
|
-
|
|
22381
|
-
|
|
22382
|
-
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
|
|
22388
|
-
|
|
22389
|
-
|
|
22390
|
-
|
|
22391
|
-
|
|
22398
|
+
function hasOwnAction(command) {
|
|
22399
|
+
return Boolean(command._actionHandler);
|
|
22400
|
+
}
|
|
22401
|
+
function longFlagSyntax(option) {
|
|
22402
|
+
return option.flags.replace(/^-[A-Za-z], /, "");
|
|
22403
|
+
}
|
|
22404
|
+
function usageExample(command) {
|
|
22405
|
+
const parts = [commandPath2(command), argumentSyntax(command)];
|
|
22406
|
+
for (const option of command.options)
|
|
22407
|
+
if (option.mandatory)
|
|
22408
|
+
parts.push(longFlagSyntax(option));
|
|
22409
|
+
return parts.filter(Boolean).join(" ");
|
|
22410
|
+
}
|
|
22411
|
+
function optionList(command) {
|
|
22412
|
+
const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
|
|
22413
|
+
return flags.length > 0 ? `Options for ${commandPath2(command)}: ${flags.join(", ")}` : `${commandPath2(command)} takes no options.`;
|
|
22414
|
+
}
|
|
22415
|
+
function unknownOptionToken(command) {
|
|
22416
|
+
return command.args.find((arg) => arg.length > 1 && arg.startsWith("-"));
|
|
22417
|
+
}
|
|
22418
|
+
function misplacedFlagValue(command) {
|
|
22419
|
+
const missing = command.options.filter((option) => option.mandatory && command.getOptionValue(option.attributeName()) === undefined);
|
|
22420
|
+
if (missing.length !== 1 || unknownOptionToken(command) !== undefined)
|
|
22421
|
+
return;
|
|
22422
|
+
if (command.registeredArguments.some((argument) => argument.variadic))
|
|
22423
|
+
return;
|
|
22424
|
+
const extra = command.args.slice(command.registeredArguments.length);
|
|
22425
|
+
return extra.length === 1 ? { option: missing[0], value: extra[0] } : undefined;
|
|
22426
|
+
}
|
|
22427
|
+
function siblingsDeclaring(command, flag) {
|
|
22428
|
+
const parent = command.parent;
|
|
22429
|
+
if (!parent)
|
|
22430
|
+
return [];
|
|
22431
|
+
return parent.createHelp().visibleCommands(parent).filter((sibling) => sibling !== command && sibling.options.some((option) => !option.hidden && (option.long === flag || option.short === flag))).map((sibling) => ` ${commandPath2(sibling)} — ${sibling.description().split(`
|
|
22432
|
+
`, 1)[0]}`);
|
|
22433
|
+
}
|
|
22434
|
+
function parseErrorGuidance(command, code) {
|
|
22435
|
+
switch (code) {
|
|
22436
|
+
case "commander.missingArgument":
|
|
22437
|
+
return [`Example: ${usageExample(command)}`];
|
|
22438
|
+
case "commander.missingMandatoryOptionValue": {
|
|
22439
|
+
const misplaced = misplacedFlagValue(command);
|
|
22440
|
+
const moved = misplaced ? [
|
|
22441
|
+
`"${misplaced.value}" was passed as a positional; pass it as ${misplaced.option.long ?? misplaced.option.short} "${misplaced.value}".`
|
|
22442
|
+
] : [];
|
|
22443
|
+
return [...moved, `Example: ${usageExample(command)}`];
|
|
22444
|
+
}
|
|
22445
|
+
case "commander.excessArguments":
|
|
22446
|
+
return [`Example: ${usageExample(command)}`, optionList(command)];
|
|
22447
|
+
case "commander.unknownOption": {
|
|
22448
|
+
const token = unknownOptionToken(command);
|
|
22392
22449
|
if (!token)
|
|
22393
|
-
return;
|
|
22450
|
+
return [];
|
|
22394
22451
|
if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
|
|
22395
|
-
|
|
22396
|
-
`);
|
|
22397
|
-
return;
|
|
22452
|
+
return [`Example: ${commandPath2(command)} -- ${token}`];
|
|
22398
22453
|
}
|
|
22399
|
-
const
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
22454
|
+
const flag = token.split("=", 1)[0];
|
|
22455
|
+
const owners = siblingsDeclaring(command, flag);
|
|
22456
|
+
return [
|
|
22457
|
+
optionList(command),
|
|
22458
|
+
...owners.length > 0 ? [`${flag} is an option of:`, ...owners] : []
|
|
22459
|
+
];
|
|
22403
22460
|
}
|
|
22404
|
-
|
|
22405
|
-
|
|
22461
|
+
default:
|
|
22462
|
+
return [];
|
|
22463
|
+
}
|
|
22464
|
+
}
|
|
22465
|
+
function addParseErrorGuidance(command) {
|
|
22466
|
+
const error = command.error.bind(command);
|
|
22467
|
+
command.error = (message, options) => {
|
|
22468
|
+
const guidance = parseErrorGuidance(command, options?.code);
|
|
22469
|
+
return error(guidance.length > 0 ? `${message}
|
|
22470
|
+
${guidance.join(`
|
|
22471
|
+
`)}` : message, options);
|
|
22472
|
+
};
|
|
22473
|
+
}
|
|
22474
|
+
function addParseErrorGuidanceToTree(program) {
|
|
22475
|
+
const walk = (command) => {
|
|
22476
|
+
const parsesOwnArguments = command.commands.length === 0 || hasOwnAction(command);
|
|
22477
|
+
if (parsesOwnArguments || !command.parent)
|
|
22478
|
+
addParseErrorGuidance(command);
|
|
22479
|
+
for (const child of command.commands)
|
|
22480
|
+
walk(child);
|
|
22481
|
+
};
|
|
22482
|
+
walk(program);
|
|
22406
22483
|
}
|
|
22407
22484
|
function assertNoReservedFlags(command, operation) {
|
|
22408
22485
|
for (const option of command.options) {
|
|
@@ -22436,7 +22513,7 @@ function assertNoReservedProgramFlags(program) {
|
|
|
22436
22513
|
function refuseHelpAfterUnknownCommand(program) {
|
|
22437
22514
|
const walk = (command) => {
|
|
22438
22515
|
const internals = command;
|
|
22439
|
-
const dispatchesOnly = command.commands.length > 0 && !
|
|
22516
|
+
const dispatchesOnly = command.commands.length > 0 && !hasOwnAction(command) && command.registeredArguments.length === 0;
|
|
22440
22517
|
if (dispatchesOnly) {
|
|
22441
22518
|
const known = new Set(["help"]);
|
|
22442
22519
|
for (const child of command.commands) {
|
|
@@ -22537,9 +22614,6 @@ function configureOperation(command, operation, spec) {
|
|
|
22537
22614
|
}));
|
|
22538
22615
|
return command;
|
|
22539
22616
|
}
|
|
22540
|
-
function buildLeaf(operation, spec, leafName) {
|
|
22541
|
-
return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
|
|
22542
|
-
}
|
|
22543
22617
|
function addRenamedCommand(groups, operation, spec, from, to) {
|
|
22544
22618
|
const segments = from.split(" ");
|
|
22545
22619
|
const [groupName, ...rest] = segments;
|
|
@@ -22549,7 +22623,7 @@ function addRenamedCommand(groups, operation, spec, from, to) {
|
|
|
22549
22623
|
for (const segment of rest.slice(0, -1)) {
|
|
22550
22624
|
parent = nestedGroup(parent, segment, { hidden: true });
|
|
22551
22625
|
}
|
|
22552
|
-
const leaf =
|
|
22626
|
+
const leaf = configureOperation(new Command(rest[rest.length - 1]), operation, spec);
|
|
22553
22627
|
leaf.hook("preAction", () => warnRenamedCommand(from, to));
|
|
22554
22628
|
addSubcommand(parent, leaf, { hidden: true });
|
|
22555
22629
|
}
|
|
@@ -22593,12 +22667,12 @@ function addLeafCommand(groups, operation, spec, segments) {
|
|
|
22593
22667
|
for (const segment of rest.slice(0, -1)) {
|
|
22594
22668
|
parent = nestedGroup(parent, segment);
|
|
22595
22669
|
}
|
|
22596
|
-
parent.addCommand(
|
|
22670
|
+
parent.addCommand(configureOperation(new Command(rest[rest.length - 1]), operation, spec), {
|
|
22597
22671
|
isDefault: spec.defaultSubcommand === true
|
|
22598
22672
|
});
|
|
22599
22673
|
return;
|
|
22600
22674
|
}
|
|
22601
|
-
group.addCommand(
|
|
22675
|
+
group.addCommand(configureOperation(new Command(rest[0]), operation, spec), {
|
|
22602
22676
|
isDefault: spec.defaultSubcommand === true
|
|
22603
22677
|
});
|
|
22604
22678
|
}
|
|
@@ -26386,6 +26460,7 @@ function buildProgram(options = {}) {
|
|
|
26386
26460
|
program.addHelpText("after", options.helpText ?? HELP_EPILOGUE);
|
|
26387
26461
|
program.addHelpText("beforeAll", ({ command }) => detectCodingAgent(env) !== undefined && command.commands.length > 0 ? AGENT_DISCOVERY_NOTE : "");
|
|
26388
26462
|
refuseHelpAfterUnknownCommand(program);
|
|
26463
|
+
addParseErrorGuidanceToTree(program);
|
|
26389
26464
|
assertNoReservedProgramFlags(program);
|
|
26390
26465
|
return program;
|
|
26391
26466
|
}
|
package/dist/runtime/build.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ import type { OperationSpec } from './types';
|
|
|
11
11
|
* caller has to name the operation it actually calls, so the two cannot drift.
|
|
12
12
|
*/
|
|
13
13
|
export declare function describeOperation(operationSpec: OperationSpec, described: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Attaches {@link addParseErrorGuidance} to every command that parses its own
|
|
16
|
+
* arguments, generated or attached by hand (`files upload`, `secrets set`), so
|
|
17
|
+
* a hand-written command does not answer a guessed flag with a bare error.
|
|
18
|
+
* Pure dispatchers below the root are left to commander's unknown-command handling.
|
|
19
|
+
*/
|
|
20
|
+
export declare function addParseErrorGuidanceToTree(program: Command): void;
|
|
14
21
|
/**
|
|
15
22
|
* Sweeps the assembled program for a flag the root already owns.
|
|
16
23
|
*
|
package/dist/runtime.js
CHANGED
|
@@ -21403,6 +21403,27 @@ async function localFile(path, override) {
|
|
|
21403
21403
|
}
|
|
21404
21404
|
|
|
21405
21405
|
// src/runtime/request.ts
|
|
21406
|
+
var BODY_VARIANT_EXAMPLES = {
|
|
21407
|
+
array: `'[{"key":"value"}]'`,
|
|
21408
|
+
object: `'{"key":"value"}'`
|
|
21409
|
+
};
|
|
21410
|
+
function jsonShape(value) {
|
|
21411
|
+
if (Array.isArray(value))
|
|
21412
|
+
return "array";
|
|
21413
|
+
if (isRecordLike(value))
|
|
21414
|
+
return "object";
|
|
21415
|
+
return;
|
|
21416
|
+
}
|
|
21417
|
+
function bodyVariantShapeError(variant, parsed, shape, variants) {
|
|
21418
|
+
const flag = `--${variant.name}`;
|
|
21419
|
+
const got = shape ? `a JSON ${shape}` : parsed === null ? "null" : `a JSON ${typeof parsed}`;
|
|
21420
|
+
const base = `${flag} must be a JSON ${variant.kind}, e.g. ${flag} ${BODY_VARIANT_EXAMPLES[variant.kind]}; got ${got}.`;
|
|
21421
|
+
if (variant.kind === "array" && isRecordLike(parsed) && Array.isArray(parsed[variant.property])) {
|
|
21422
|
+
return `${base} Pass the array under its "${variant.property}" key itself, not the object wrapping it.`;
|
|
21423
|
+
}
|
|
21424
|
+
const other = shape && variants.find((candidate) => candidate !== variant && candidate.kind === shape);
|
|
21425
|
+
return other ? `${base} For that shape use --${other.name}.` : base;
|
|
21426
|
+
}
|
|
21406
21427
|
var PROFILE_INJECTED_FIELD = "workspaceId";
|
|
21407
21428
|
function isProfileWorkspacePath(commandSpec, param) {
|
|
21408
21429
|
return commandSpec.profileWorkspacePath === true && param === PROFILE_INJECTED_FIELD;
|
|
@@ -21774,8 +21795,9 @@ async function buildRequest(operation, positional, flags, workspaceId) {
|
|
|
21774
21795
|
if (typeof raw !== "string")
|
|
21775
21796
|
throw new SimApiError(`--${variant.name} is required`, 0);
|
|
21776
21797
|
const parsed = await coerce(raw, { kind: variant.kind }, { json: true }, variant.name);
|
|
21777
|
-
|
|
21778
|
-
|
|
21798
|
+
const shape = jsonShape(parsed);
|
|
21799
|
+
if (shape !== variant.kind) {
|
|
21800
|
+
throw new SimApiError(bodyVariantShapeError(variant, parsed, shape, commandSpec.bodyVariants), 0);
|
|
21779
21801
|
}
|
|
21780
21802
|
return boundedRequest({
|
|
21781
21803
|
params,
|
|
@@ -22419,39 +22441,94 @@ function commandPath2(command) {
|
|
|
22419
22441
|
}
|
|
22420
22442
|
return names.join(" ");
|
|
22421
22443
|
}
|
|
22422
|
-
var UNKNOWN_OPTION_TOKEN = /^error: unknown option '(.+?)'/;
|
|
22423
22444
|
function looksLikeAnId(token) {
|
|
22424
22445
|
return token.length > 2 && !token.startsWith("--") && /^-[A-Za-z0-9_-]*[A-Z0-9][A-Za-z0-9_-]*$/.test(token);
|
|
22425
22446
|
}
|
|
22426
|
-
function
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
|
|
22434
|
-
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
|
|
22447
|
+
function hasOwnAction(command) {
|
|
22448
|
+
return Boolean(command._actionHandler);
|
|
22449
|
+
}
|
|
22450
|
+
function longFlagSyntax(option) {
|
|
22451
|
+
return option.flags.replace(/^-[A-Za-z], /, "");
|
|
22452
|
+
}
|
|
22453
|
+
function usageExample(command) {
|
|
22454
|
+
const parts = [commandPath2(command), argumentSyntax(command)];
|
|
22455
|
+
for (const option of command.options)
|
|
22456
|
+
if (option.mandatory)
|
|
22457
|
+
parts.push(longFlagSyntax(option));
|
|
22458
|
+
return parts.filter(Boolean).join(" ");
|
|
22459
|
+
}
|
|
22460
|
+
function optionList(command) {
|
|
22461
|
+
const flags = command.options.filter((option) => !option.hidden).map((option) => option.flags);
|
|
22462
|
+
return flags.length > 0 ? `Options for ${commandPath2(command)}: ${flags.join(", ")}` : `${commandPath2(command)} takes no options.`;
|
|
22463
|
+
}
|
|
22464
|
+
function unknownOptionToken(command) {
|
|
22465
|
+
return command.args.find((arg) => arg.length > 1 && arg.startsWith("-"));
|
|
22466
|
+
}
|
|
22467
|
+
function misplacedFlagValue(command) {
|
|
22468
|
+
const missing = command.options.filter((option) => option.mandatory && command.getOptionValue(option.attributeName()) === undefined);
|
|
22469
|
+
if (missing.length !== 1 || unknownOptionToken(command) !== undefined)
|
|
22470
|
+
return;
|
|
22471
|
+
if (command.registeredArguments.some((argument) => argument.variadic))
|
|
22472
|
+
return;
|
|
22473
|
+
const extra = command.args.slice(command.registeredArguments.length);
|
|
22474
|
+
return extra.length === 1 ? { option: missing[0], value: extra[0] } : undefined;
|
|
22475
|
+
}
|
|
22476
|
+
function siblingsDeclaring(command, flag) {
|
|
22477
|
+
const parent = command.parent;
|
|
22478
|
+
if (!parent)
|
|
22479
|
+
return [];
|
|
22480
|
+
return parent.createHelp().visibleCommands(parent).filter((sibling) => sibling !== command && sibling.options.some((option) => !option.hidden && (option.long === flag || option.short === flag))).map((sibling) => ` ${commandPath2(sibling)} — ${sibling.description().split(`
|
|
22481
|
+
`, 1)[0]}`);
|
|
22482
|
+
}
|
|
22483
|
+
function parseErrorGuidance(command, code) {
|
|
22484
|
+
switch (code) {
|
|
22485
|
+
case "commander.missingArgument":
|
|
22486
|
+
return [`Example: ${usageExample(command)}`];
|
|
22487
|
+
case "commander.missingMandatoryOptionValue": {
|
|
22488
|
+
const misplaced = misplacedFlagValue(command);
|
|
22489
|
+
const moved = misplaced ? [
|
|
22490
|
+
`"${misplaced.value}" was passed as a positional; pass it as ${misplaced.option.long ?? misplaced.option.short} "${misplaced.value}".`
|
|
22491
|
+
] : [];
|
|
22492
|
+
return [...moved, `Example: ${usageExample(command)}`];
|
|
22493
|
+
}
|
|
22494
|
+
case "commander.excessArguments":
|
|
22495
|
+
return [`Example: ${usageExample(command)}`, optionList(command)];
|
|
22496
|
+
case "commander.unknownOption": {
|
|
22497
|
+
const token = unknownOptionToken(command);
|
|
22441
22498
|
if (!token)
|
|
22442
|
-
return;
|
|
22499
|
+
return [];
|
|
22443
22500
|
if (looksLikeAnId(token) && command.registeredArguments.length > 0) {
|
|
22444
|
-
|
|
22445
|
-
`);
|
|
22446
|
-
return;
|
|
22501
|
+
return [`Example: ${commandPath2(command)} -- ${token}`];
|
|
22447
22502
|
}
|
|
22448
|
-
const
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22503
|
+
const flag = token.split("=", 1)[0];
|
|
22504
|
+
const owners = siblingsDeclaring(command, flag);
|
|
22505
|
+
return [
|
|
22506
|
+
optionList(command),
|
|
22507
|
+
...owners.length > 0 ? [`${flag} is an option of:`, ...owners] : []
|
|
22508
|
+
];
|
|
22452
22509
|
}
|
|
22453
|
-
|
|
22454
|
-
|
|
22510
|
+
default:
|
|
22511
|
+
return [];
|
|
22512
|
+
}
|
|
22513
|
+
}
|
|
22514
|
+
function addParseErrorGuidance(command) {
|
|
22515
|
+
const error = command.error.bind(command);
|
|
22516
|
+
command.error = (message, options) => {
|
|
22517
|
+
const guidance = parseErrorGuidance(command, options?.code);
|
|
22518
|
+
return error(guidance.length > 0 ? `${message}
|
|
22519
|
+
${guidance.join(`
|
|
22520
|
+
`)}` : message, options);
|
|
22521
|
+
};
|
|
22522
|
+
}
|
|
22523
|
+
function addParseErrorGuidanceToTree(program) {
|
|
22524
|
+
const walk = (command) => {
|
|
22525
|
+
const parsesOwnArguments = command.commands.length === 0 || hasOwnAction(command);
|
|
22526
|
+
if (parsesOwnArguments || !command.parent)
|
|
22527
|
+
addParseErrorGuidance(command);
|
|
22528
|
+
for (const child of command.commands)
|
|
22529
|
+
walk(child);
|
|
22530
|
+
};
|
|
22531
|
+
walk(program);
|
|
22455
22532
|
}
|
|
22456
22533
|
function assertNoReservedFlags(command, operation) {
|
|
22457
22534
|
for (const option of command.options) {
|
|
@@ -22485,7 +22562,7 @@ function assertNoReservedProgramFlags(program) {
|
|
|
22485
22562
|
function refuseHelpAfterUnknownCommand(program) {
|
|
22486
22563
|
const walk = (command) => {
|
|
22487
22564
|
const internals = command;
|
|
22488
|
-
const dispatchesOnly = command.commands.length > 0 && !
|
|
22565
|
+
const dispatchesOnly = command.commands.length > 0 && !hasOwnAction(command) && command.registeredArguments.length === 0;
|
|
22489
22566
|
if (dispatchesOnly) {
|
|
22490
22567
|
const known = new Set(["help"]);
|
|
22491
22568
|
for (const child of command.commands) {
|
|
@@ -22586,9 +22663,6 @@ function configureOperation(command, operation, spec) {
|
|
|
22586
22663
|
}));
|
|
22587
22664
|
return command;
|
|
22588
22665
|
}
|
|
22589
|
-
function buildLeaf(operation, spec, leafName) {
|
|
22590
|
-
return addParseErrorGuidance(configureOperation(new Command(leafName), operation, spec));
|
|
22591
|
-
}
|
|
22592
22666
|
function addRenamedCommand(groups, operation, spec, from, to) {
|
|
22593
22667
|
const segments = from.split(" ");
|
|
22594
22668
|
const [groupName, ...rest] = segments;
|
|
@@ -22598,7 +22672,7 @@ function addRenamedCommand(groups, operation, spec, from, to) {
|
|
|
22598
22672
|
for (const segment of rest.slice(0, -1)) {
|
|
22599
22673
|
parent = nestedGroup(parent, segment, { hidden: true });
|
|
22600
22674
|
}
|
|
22601
|
-
const leaf =
|
|
22675
|
+
const leaf = configureOperation(new Command(rest[rest.length - 1]), operation, spec);
|
|
22602
22676
|
leaf.hook("preAction", () => warnRenamedCommand(from, to));
|
|
22603
22677
|
addSubcommand(parent, leaf, { hidden: true });
|
|
22604
22678
|
}
|
|
@@ -22642,12 +22716,12 @@ function addLeafCommand(groups, operation, spec, segments) {
|
|
|
22642
22716
|
for (const segment of rest.slice(0, -1)) {
|
|
22643
22717
|
parent = nestedGroup(parent, segment);
|
|
22644
22718
|
}
|
|
22645
|
-
parent.addCommand(
|
|
22719
|
+
parent.addCommand(configureOperation(new Command(rest[rest.length - 1]), operation, spec), {
|
|
22646
22720
|
isDefault: spec.defaultSubcommand === true
|
|
22647
22721
|
});
|
|
22648
22722
|
return;
|
|
22649
22723
|
}
|
|
22650
|
-
group.addCommand(
|
|
22724
|
+
group.addCommand(configureOperation(new Command(rest[0]), operation, spec), {
|
|
22651
22725
|
isDefault: spec.defaultSubcommand === true
|
|
22652
22726
|
});
|
|
22653
22727
|
}
|
|
@@ -26435,6 +26509,7 @@ function buildProgram(options = {}) {
|
|
|
26435
26509
|
program.addHelpText("after", options.helpText ?? HELP_EPILOGUE);
|
|
26436
26510
|
program.addHelpText("beforeAll", ({ command }) => detectCodingAgent(env) !== undefined && command.commands.length > 0 ? AGENT_DISCOVERY_NOTE : "");
|
|
26437
26511
|
refuseHelpAfterUnknownCommand(program);
|
|
26512
|
+
addParseErrorGuidanceToTree(program);
|
|
26438
26513
|
assertNoReservedProgramFlags(program);
|
|
26439
26514
|
return program;
|
|
26440
26515
|
}
|