@dalmia/calibrate-mcp 0.0.30 → 0.0.32
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/bin/mcp-server.js +647 -386
- package/bin/mcp-server.js.map +16 -16
- package/esm/landing-page.js +1 -1
- package/esm/lib/config.d.ts +2 -2
- package/esm/lib/config.js +2 -2
- package/esm/mcp-server/mcp-server.js +1 -1
- package/esm/mcp-server/server.js +1 -1
- package/esm/models/agentsummary.d.ts +1 -0
- package/esm/models/agentsummary.d.ts.map +1 -1
- package/esm/models/agentsummary.js +1 -0
- package/esm/models/agentsummary.js.map +1 -1
- package/esm/models/annotationtaskresponse.d.ts +1 -0
- package/esm/models/annotationtaskresponse.d.ts.map +1 -1
- package/esm/models/annotationtaskresponse.js +1 -0
- package/esm/models/annotationtaskresponse.js.map +1 -1
- package/esm/models/benchmarkstatusresponse.d.ts +1 -0
- package/esm/models/benchmarkstatusresponse.d.ts.map +1 -1
- package/esm/models/benchmarkstatusresponse.js +1 -0
- package/esm/models/benchmarkstatusresponse.js.map +1 -1
- package/esm/models/bulktestitem.d.ts +3 -0
- package/esm/models/bulktestitem.d.ts.map +1 -1
- package/esm/models/bulktestitem.js +1 -0
- package/esm/models/bulktestitem.js.map +1 -1
- package/esm/models/taskagreementresponse.js +1 -1
- package/esm/models/taskagreementresponse.js.map +1 -1
- package/esm/models/testcaseresult.d.ts +3 -0
- package/esm/models/testcaseresult.d.ts.map +1 -1
- package/esm/models/testcaseresult.js +1 -0
- package/esm/models/testcaseresult.js.map +1 -1
- package/esm/models/testrunstatusresponse.d.ts +1 -0
- package/esm/models/testrunstatusresponse.d.ts.map +1 -1
- package/esm/models/testrunstatusresponse.js +1 -0
- package/esm/models/testrunstatusresponse.js.map +1 -1
- package/package.json +1 -1
- package/src/landing-page.ts +1 -1
- package/src/lib/config.ts +2 -2
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
- package/src/models/agentsummary.ts +4 -0
- package/src/models/annotationtaskresponse.ts +4 -0
- package/src/models/benchmarkstatusresponse.ts +4 -0
- package/src/models/bulktestitem.ts +4 -0
- package/src/models/taskagreementresponse.ts +1 -1
- package/src/models/testcaseresult.ts +4 -0
- package/src/models/testrunstatusresponse.ts +4 -0
package/bin/mcp-server.js
CHANGED
|
@@ -1021,10 +1021,10 @@ function datetime(args) {
|
|
|
1021
1021
|
const timeRegex = `${time2}(?:${opts.join("|")})`;
|
|
1022
1022
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
1023
1023
|
}
|
|
1024
|
-
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid = (
|
|
1025
|
-
if (!
|
|
1024
|
+
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid = (version2) => {
|
|
1025
|
+
if (!version2)
|
|
1026
1026
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
1027
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${
|
|
1027
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
1028
1028
|
}, email, _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, httpProtocol, e164, dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`, date, string = (params) => {
|
|
1029
1029
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
1030
1030
|
return new RegExp(`^${regex}$`);
|
|
@@ -1491,9 +1491,9 @@ class Doc {
|
|
|
1491
1491
|
}
|
|
1492
1492
|
|
|
1493
1493
|
// node_modules/zod/v4/core/versions.js
|
|
1494
|
-
var
|
|
1494
|
+
var version2;
|
|
1495
1495
|
var init_versions = __esm(() => {
|
|
1496
|
-
|
|
1496
|
+
version2 = {
|
|
1497
1497
|
major: 4,
|
|
1498
1498
|
minor: 4,
|
|
1499
1499
|
patch: 3
|
|
@@ -1793,7 +1793,7 @@ var init_schemas = __esm(() => {
|
|
|
1793
1793
|
inst ?? (inst = {});
|
|
1794
1794
|
inst._zod.def = def;
|
|
1795
1795
|
inst._zod.bag = inst._zod.bag || {};
|
|
1796
|
-
inst._zod.version =
|
|
1796
|
+
inst._zod.version = version2;
|
|
1797
1797
|
const checks = [...inst._zod.def.checks ?? []];
|
|
1798
1798
|
if (inst._zod.traits.has("$ZodCheck")) {
|
|
1799
1799
|
checks.unshift(inst);
|
|
@@ -8247,10 +8247,10 @@ var require_supports_color = __commonJS((exports, module) => {
|
|
|
8247
8247
|
return 3;
|
|
8248
8248
|
}
|
|
8249
8249
|
if ("TERM_PROGRAM" in env) {
|
|
8250
|
-
const
|
|
8250
|
+
const version3 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
8251
8251
|
switch (env.TERM_PROGRAM) {
|
|
8252
8252
|
case "iTerm.app":
|
|
8253
|
-
return
|
|
8253
|
+
return version3 >= 3 ? 3 : 2;
|
|
8254
8254
|
case "Apple_Terminal":
|
|
8255
8255
|
return 2;
|
|
8256
8256
|
}
|
|
@@ -22971,18 +22971,12 @@ var require_media_typer = __commonJS((exports) => {
|
|
|
22971
22971
|
return string4;
|
|
22972
22972
|
}
|
|
22973
22973
|
function test(string4) {
|
|
22974
|
-
if (!string4) {
|
|
22975
|
-
throw new TypeError("argument string is required");
|
|
22976
|
-
}
|
|
22977
22974
|
if (typeof string4 !== "string") {
|
|
22978
22975
|
throw new TypeError("argument string is required to be a string");
|
|
22979
22976
|
}
|
|
22980
22977
|
return TYPE_REGEXP.test(string4.toLowerCase());
|
|
22981
22978
|
}
|
|
22982
22979
|
function parse5(string4) {
|
|
22983
|
-
if (!string4) {
|
|
22984
|
-
throw new TypeError("argument string is required");
|
|
22985
|
-
}
|
|
22986
22980
|
if (typeof string4 !== "string") {
|
|
22987
22981
|
throw new TypeError("argument string is required to be a string");
|
|
22988
22982
|
}
|
|
@@ -32341,11 +32335,11 @@ function datetimeRegex(args) {
|
|
|
32341
32335
|
regex = `${regex}(${opts.join("|")})`;
|
|
32342
32336
|
return new RegExp(`^${regex}$`);
|
|
32343
32337
|
}
|
|
32344
|
-
function isValidIP(ip,
|
|
32345
|
-
if ((
|
|
32338
|
+
function isValidIP(ip, version3) {
|
|
32339
|
+
if ((version3 === "v4" || !version3) && ipv4Regex.test(ip)) {
|
|
32346
32340
|
return true;
|
|
32347
32341
|
}
|
|
32348
|
-
if ((
|
|
32342
|
+
if ((version3 === "v6" || !version3) && ipv6Regex.test(ip)) {
|
|
32349
32343
|
return true;
|
|
32350
32344
|
}
|
|
32351
32345
|
return false;
|
|
@@ -32372,11 +32366,11 @@ function isValidJWT2(jwt, alg) {
|
|
|
32372
32366
|
return false;
|
|
32373
32367
|
}
|
|
32374
32368
|
}
|
|
32375
|
-
function isValidCidr(ip,
|
|
32376
|
-
if ((
|
|
32369
|
+
function isValidCidr(ip, version3) {
|
|
32370
|
+
if ((version3 === "v4" || !version3) && ipv4CidrRegex.test(ip)) {
|
|
32377
32371
|
return true;
|
|
32378
32372
|
}
|
|
32379
|
-
if ((
|
|
32373
|
+
if ((version3 === "v6" || !version3) && ipv6CidrRegex.test(ip)) {
|
|
32380
32374
|
return true;
|
|
32381
32375
|
}
|
|
32382
32376
|
return false;
|
|
@@ -41433,7 +41427,12 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
41433
41427
|
}
|
|
41434
41428
|
function resolve(baseURI, relativeURI, options) {
|
|
41435
41429
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
41436
|
-
const
|
|
41430
|
+
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
41431
|
+
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
41432
|
+
if (baseMalformed || relativeMalformed) {
|
|
41433
|
+
throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
|
|
41434
|
+
}
|
|
41435
|
+
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
41437
41436
|
schemelessOptions.skipEscape = true;
|
|
41438
41437
|
return serialize(resolved, schemelessOptions);
|
|
41439
41438
|
}
|
|
@@ -41559,6 +41558,8 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
41559
41558
|
return uriTokens.join("");
|
|
41560
41559
|
}
|
|
41561
41560
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
41561
|
+
var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
|
|
41562
|
+
var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
|
|
41562
41563
|
function getParseError(parsed, matches) {
|
|
41563
41564
|
if (matches[2] !== undefined && parsed.path && parsed.path[0] !== "/") {
|
|
41564
41565
|
return 'URI path must start with "/" when authority is present.';
|
|
@@ -41588,6 +41589,25 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
41588
41589
|
uri = "//" + uri;
|
|
41589
41590
|
}
|
|
41590
41591
|
}
|
|
41592
|
+
const authorityMatch = uri.match(AUTHORITY_PREFIX);
|
|
41593
|
+
if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
|
|
41594
|
+
parsed.error = "URI authority must not contain a literal backslash.";
|
|
41595
|
+
malformedAuthorityOrPort = true;
|
|
41596
|
+
}
|
|
41597
|
+
const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
|
|
41598
|
+
if (introducerMatch !== null) {
|
|
41599
|
+
const region = introducerMatch[1];
|
|
41600
|
+
const normalizedRegion = region.replace(/[\t\n\r]/g, "");
|
|
41601
|
+
if (normalizedRegion.length >= 2) {
|
|
41602
|
+
if (normalizedRegion.slice(0, 2) !== "//") {
|
|
41603
|
+
parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
|
|
41604
|
+
malformedAuthorityOrPort = true;
|
|
41605
|
+
} else if (region.length !== normalizedRegion.length) {
|
|
41606
|
+
parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
|
|
41607
|
+
malformedAuthorityOrPort = true;
|
|
41608
|
+
}
|
|
41609
|
+
}
|
|
41610
|
+
}
|
|
41591
41611
|
const matches = uri.match(URI_PARSE);
|
|
41592
41612
|
if (matches) {
|
|
41593
41613
|
parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase();
|
|
@@ -51392,9 +51412,9 @@ var init_config = __esm(() => {
|
|
|
51392
51412
|
SDK_METADATA = {
|
|
51393
51413
|
language: "typescript",
|
|
51394
51414
|
openapiDocVersion: "0.1.0",
|
|
51395
|
-
sdkVersion: "0.0.
|
|
51415
|
+
sdkVersion: "0.0.32",
|
|
51396
51416
|
genVersion: "2.915.1",
|
|
51397
|
-
userAgent: "speakeasy-sdk/mcp-typescript 0.0.
|
|
51417
|
+
userAgent: "speakeasy-sdk/mcp-typescript 0.0.32 2.915.1 0.1.0 @dalmia/calibrate-mcp"
|
|
51398
51418
|
};
|
|
51399
51419
|
});
|
|
51400
51420
|
|
|
@@ -53374,6 +53394,7 @@ var init_agentsummary = __esm(() => {
|
|
|
53374
53394
|
]).describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate");
|
|
53375
53395
|
AgentSummary$zodSchema = object({
|
|
53376
53396
|
connection_verified: boolean2().nullable().optional().describe("Whether the agent's connection has been verified, for a `type=connection` agent"),
|
|
53397
|
+
has_default_inputs: boolean2().describe("Whether the agent has custom request fields configured"),
|
|
53377
53398
|
name: string2().describe("Name of the agent"),
|
|
53378
53399
|
type: AgentSummaryType$zodSchema.describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate"),
|
|
53379
53400
|
updated_at: string2().describe("When the agent was last updated (ISO 8601 UTC)"),
|
|
@@ -54409,6 +54430,7 @@ var init_testcaseresult = __esm(() => {
|
|
|
54409
54430
|
init_testoutput();
|
|
54410
54431
|
TestCaseResult$zodSchema = object({
|
|
54411
54432
|
cost: number2().nullable().optional().describe("Cost of this case (USD)"),
|
|
54433
|
+
inputs: record(string2(), any()).nullable().optional().describe("Extra request fields sent to the agent for this case, the agent's `default_inputs` with this case's overrides applied"),
|
|
54412
54434
|
judge_results: array(JudgeResult$zodSchema).nullable().optional().describe("One verdict for each evaluator"),
|
|
54413
54435
|
latency_ms: number2().nullable().optional().describe("How long the agent took to respond, in milliseconds"),
|
|
54414
54436
|
name: string2().nullable().optional().describe("Name of the test"),
|
|
@@ -54488,7 +54510,8 @@ var init_benchmarkstatusresponse = __esm(() => {
|
|
|
54488
54510
|
model_results: array(ModelResult$zodSchema).nullable().optional().describe("Results for each model"),
|
|
54489
54511
|
share_token: string2().nullable().optional().describe("Token for building the public share URL"),
|
|
54490
54512
|
status: TaskStatus$zodSchema,
|
|
54491
|
-
task_id: string2().describe("Benchmark run job ID")
|
|
54513
|
+
task_id: string2().describe("Benchmark run job ID"),
|
|
54514
|
+
test_uuids: array(string2()).nullable().optional().describe("IDs of the tests this benchmark executed, in run order")
|
|
54492
54515
|
});
|
|
54493
54516
|
});
|
|
54494
54517
|
|
|
@@ -54651,6 +54674,7 @@ var init_testrunstatusresponse = __esm(() => {
|
|
|
54651
54674
|
share_token: string2().nullable().optional().describe("Token for building the public share URL"),
|
|
54652
54675
|
status: TaskStatus$zodSchema,
|
|
54653
54676
|
task_id: string2().describe("Test run job ID"),
|
|
54677
|
+
test_uuids: array(string2()).nullable().optional().describe("IDs of the tests this run executed, in run order"),
|
|
54654
54678
|
total_tests: int().nullable().optional().describe("Total number of test cases"),
|
|
54655
54679
|
total_tokens: record(string2(), any()).nullable().optional().describe("Aggregated token usage as `{mean, min, max, count}`")
|
|
54656
54680
|
});
|
|
@@ -56207,6 +56231,7 @@ var init_annotationtaskresponse = __esm(() => {
|
|
|
56207
56231
|
created_at: string2().describe("When the task was created (ISO 8601 UTC)"),
|
|
56208
56232
|
description: string2().nullable().optional().describe("The task's description"),
|
|
56209
56233
|
evaluators: array(record(string2(), any())).optional().describe("The evaluators linked to this task, in display order. Fetching one task by ID enriches each with its live version's rubric. Listing tasks returns lightweight metadata (uuid, name, type, position) only"),
|
|
56234
|
+
has_agreement: boolean2().default(false).describe("Whether the task has at least one comparable human-vs-human or human-vs-evaluator pair, computed over all time"),
|
|
56210
56235
|
item_count: int().nullable().optional().describe("Number of items in the task"),
|
|
56211
56236
|
items: array(record(string2(), any())).optional().describe("The task's items, each with its agreement stats. You get these when you fetch one task by ID, not when you list tasks"),
|
|
56212
56237
|
jobs: array(record(string2(), any())).optional().describe("The task's labelling jobs. You get these when you fetch one task by ID, not when you list tasks"),
|
|
@@ -56383,7 +56408,7 @@ var init_taskagreementresponse = __esm(() => {
|
|
|
56383
56408
|
TaskAgreementResponse$zodSchema = collectExtraKeys(object({
|
|
56384
56409
|
bucket: string2().describe("Time bucket used for the trend series"),
|
|
56385
56410
|
days: int().describe("Length of the trailing window in days"),
|
|
56386
|
-
evaluators: array(record(string2(), any())).describe("Agreement between each evaluator and the annotators, one entry per linked evaluator"),
|
|
56411
|
+
evaluators: array(record(string2(), any())).describe("Agreement between each evaluator and the annotators, plus that evaluator's own results, one entry per linked evaluator"),
|
|
56387
56412
|
human_human: HumanAgreementBlock$zodSchema,
|
|
56388
56413
|
task_id: string2().describe("ID of the task")
|
|
56389
56414
|
}).catchall(any()), "AdditionalProperties", true);
|
|
@@ -58174,6 +58199,7 @@ var init_bulktestitem = __esm(() => {
|
|
|
58174
58199
|
BulkTestItem$zodSchema = object({
|
|
58175
58200
|
conversation_history: array(ChatMessage$zodSchema).describe("Ordered messages ending at the user turn the agent should answer"),
|
|
58176
58201
|
evaluators: array(RoutersTestsEvaluatorRef$zodSchema).nullable().optional().describe("Evaluators to link. Used by `response` and `conversation` tests"),
|
|
58202
|
+
inputs: record(string2(), any()).nullable().optional().describe("Extra request fields for this test, overriding the agent's `default_inputs` per key"),
|
|
58177
58203
|
name: string2().describe("Name of the test, unique within the workspace and within the batch"),
|
|
58178
58204
|
tool_calls: array(ExpectedToolCall$zodSchema).nullable().optional().describe("Expected tool calls. **Required for `tool_call` batches**")
|
|
58179
58205
|
});
|
|
@@ -58972,7 +58998,7 @@ fields to change (name, config). Returns the updated test. Fails with
|
|
|
58972
58998
|
function createMCPServer(deps) {
|
|
58973
58999
|
const server = new McpServer({
|
|
58974
59000
|
name: "CalibrateMcp",
|
|
58975
|
-
version: "0.0.
|
|
59001
|
+
version: "0.0.32"
|
|
58976
59002
|
});
|
|
58977
59003
|
const getClient = deps.getSDK || (() => new CalibrateMcpCore({
|
|
58978
59004
|
security: deps.security,
|
|
@@ -60199,7 +60225,7 @@ http_headers = { "api-key-auth" = "YOUR_API_KEY_AUTH" }`;
|
|
|
60199
60225
|
<h1>Instructions</h1>
|
|
60200
60226
|
<p>One-click installation for Claude Desktop users</p>
|
|
60201
60227
|
<div class="instruction-item">
|
|
60202
|
-
<a href="https://github.com/dalmia/calibrate-mcp/releases/download/v0.0.
|
|
60228
|
+
<a href="https://github.com/dalmia/calibrate-mcp/releases/download/v0.0.32/mcp-server.mcpb" download="mcp-server.mcpb" class="action-button header-action" style="display: inline-flex; margin-bottom: 16px;">
|
|
60203
60229
|
\uD83D\uDCE5 Download MCP Bundle
|
|
60204
60230
|
</a>
|
|
60205
60231
|
</div>
|
|
@@ -60810,23 +60836,8 @@ var init_impl2 = __esm(() => {
|
|
|
60810
60836
|
});
|
|
60811
60837
|
|
|
60812
60838
|
// node_modules/@stricli/core/dist/index.js
|
|
60813
|
-
var TRUTHY_VALUES = /* @__PURE__ */ new Set(["true", "t", "yes", "y", "on", "1", ""]);
|
|
60814
|
-
var FALSY_VALUES = /* @__PURE__ */ new Set(["false", "f", "no", "n", "off", "0"]);
|
|
60815
|
-
var looseBooleanParser = (input) => {
|
|
60816
|
-
const value = input.toLowerCase();
|
|
60817
|
-
if (TRUTHY_VALUES.has(value)) {
|
|
60818
|
-
return true;
|
|
60819
|
-
}
|
|
60820
|
-
if (FALSY_VALUES.has(value)) {
|
|
60821
|
-
return false;
|
|
60822
|
-
}
|
|
60823
|
-
throw new SyntaxError(`Cannot convert ${input} to a boolean`);
|
|
60824
|
-
};
|
|
60825
|
-
function checkEnvironmentVariable(process2, varName) {
|
|
60826
|
-
const value = process2.env?.[varName];
|
|
60827
|
-
return typeof value === "string" && looseBooleanParser(value);
|
|
60828
|
-
}
|
|
60829
60839
|
var ExitCode = {
|
|
60840
|
+
IntegrationError: -10,
|
|
60830
60841
|
UnknownCommand: -5,
|
|
60831
60842
|
InvalidArgument: -4,
|
|
60832
60843
|
ContextLoadError: -3,
|
|
@@ -60995,6 +61006,18 @@ async function allSettledOrElse(values) {
|
|
|
60995
61006
|
}
|
|
60996
61007
|
return { status: "fulfilled", value: grouped.fulfilled?.map((result) => result.value) ?? [] };
|
|
60997
61008
|
}
|
|
61009
|
+
var TRUTHY_VALUES = /* @__PURE__ */ new Set(["true", "t", "yes", "y", "on", "1", ""]);
|
|
61010
|
+
var FALSY_VALUES = /* @__PURE__ */ new Set(["false", "f", "no", "n", "off", "0"]);
|
|
61011
|
+
var looseBooleanParser = (input) => {
|
|
61012
|
+
const value = input.toLowerCase();
|
|
61013
|
+
if (TRUTHY_VALUES.has(value)) {
|
|
61014
|
+
return true;
|
|
61015
|
+
}
|
|
61016
|
+
if (FALSY_VALUES.has(value)) {
|
|
61017
|
+
return false;
|
|
61018
|
+
}
|
|
61019
|
+
throw new SyntaxError(`Cannot convert ${input} to a boolean`);
|
|
61020
|
+
};
|
|
60998
61021
|
var numberParser = (input) => {
|
|
60999
61022
|
const value = Number(input);
|
|
61000
61023
|
if (Number.isNaN(value)) {
|
|
@@ -61013,6 +61036,11 @@ function formatMessageForArgumentScannerError(error, formatter) {
|
|
|
61013
61036
|
}
|
|
61014
61037
|
return error.message;
|
|
61015
61038
|
}
|
|
61039
|
+
function resolveAllowedNegationForFlags(flags) {
|
|
61040
|
+
return Object.fromEntries(Object.entries(flags).map(([internalFlagName, flag]) => {
|
|
61041
|
+
return [internalFlagName, flag.kind === "boolean" && flag.withNegated !== false];
|
|
61042
|
+
}));
|
|
61043
|
+
}
|
|
61016
61044
|
function resolveAliases(flags, aliases, scannerCaseStyle) {
|
|
61017
61045
|
return Object.fromEntries(Object.entries(aliases).map(([alias, internalFlagName_]) => {
|
|
61018
61046
|
const internalFlagName = internalFlagName_;
|
|
@@ -61156,7 +61184,7 @@ function undoNegation(flagName) {
|
|
|
61156
61184
|
return firstLower + flagName.slice(3);
|
|
61157
61185
|
}
|
|
61158
61186
|
}
|
|
61159
|
-
function findInternalFlagMatch(externalFlagName, flags, config) {
|
|
61187
|
+
function findInternalFlagMatch(externalFlagName, flags, allowsNegation, config) {
|
|
61160
61188
|
const internalFlagName = externalFlagName;
|
|
61161
61189
|
let flag = flags[internalFlagName];
|
|
61162
61190
|
let foundFlagWithNegatedFalse;
|
|
@@ -61165,9 +61193,9 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
|
|
|
61165
61193
|
const internalWithoutNegation = undoNegation(internalFlagName);
|
|
61166
61194
|
if (internalWithoutNegation) {
|
|
61167
61195
|
flag = flags[internalWithoutNegation];
|
|
61168
|
-
if (flag
|
|
61169
|
-
if (
|
|
61170
|
-
return
|
|
61196
|
+
if (flag) {
|
|
61197
|
+
if (allowsNegation[internalWithoutNegation]) {
|
|
61198
|
+
return [internalWithoutNegation, flag, true];
|
|
61171
61199
|
} else {
|
|
61172
61200
|
foundFlagWithNegatedFalse = internalWithoutNegation;
|
|
61173
61201
|
flag = undefined;
|
|
@@ -61179,14 +61207,14 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
|
|
|
61179
61207
|
if (config.caseStyle === "allow-kebab-for-camel" && !flag) {
|
|
61180
61208
|
flag = flags[camelCaseFlagName];
|
|
61181
61209
|
if (flag) {
|
|
61182
|
-
return
|
|
61210
|
+
return [camelCaseFlagName, flag];
|
|
61183
61211
|
}
|
|
61184
61212
|
const camelCaseWithoutNegation = undoNegation(camelCaseFlagName);
|
|
61185
61213
|
if (camelCaseWithoutNegation) {
|
|
61186
61214
|
flag = flags[camelCaseWithoutNegation];
|
|
61187
|
-
if (flag
|
|
61188
|
-
if (
|
|
61189
|
-
return
|
|
61215
|
+
if (flag) {
|
|
61216
|
+
if (allowsNegation[camelCaseWithoutNegation]) {
|
|
61217
|
+
return [camelCaseWithoutNegation, flag, true];
|
|
61190
61218
|
} else {
|
|
61191
61219
|
foundFlagWithNegatedFalse = camelCaseWithoutNegation;
|
|
61192
61220
|
foundFlagWithNegatedFalseFromKebabConversion = true;
|
|
@@ -61213,17 +61241,17 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
|
|
|
61213
61241
|
const corrections = filterClosestAlternatives(internalFlagName, Object.keys(flags), config.distanceOptions);
|
|
61214
61242
|
throw new FlagNotFoundError(externalFlagName, corrections);
|
|
61215
61243
|
}
|
|
61216
|
-
return
|
|
61244
|
+
return [internalFlagName, flag];
|
|
61217
61245
|
}
|
|
61218
61246
|
function isNiladic(namedFlagWithNegation) {
|
|
61219
|
-
if (namedFlagWithNegation
|
|
61247
|
+
if (namedFlagWithNegation[1].kind === "boolean" || namedFlagWithNegation[1].kind === "counter") {
|
|
61220
61248
|
return true;
|
|
61221
61249
|
}
|
|
61222
61250
|
return false;
|
|
61223
61251
|
}
|
|
61224
61252
|
var FLAG_SHORTHAND_PATTERN = /^-([a-z]+)$/i;
|
|
61225
61253
|
var FLAG_NAME_PATTERN = /^--([a-z][a-z-.\d_]+)$/i;
|
|
61226
|
-
function findFlagsByArgument(arg, flags, resolvedAliases, config) {
|
|
61254
|
+
function findFlagsByArgument(arg, flags, allowsNegation, resolvedAliases, config) {
|
|
61227
61255
|
const shorthandMatch = FLAG_SHORTHAND_PATTERN.exec(arg);
|
|
61228
61256
|
if (shorthandMatch) {
|
|
61229
61257
|
const batch = shorthandMatch[1];
|
|
@@ -61233,13 +61261,13 @@ function findFlagsByArgument(arg, flags, resolvedAliases, config) {
|
|
|
61233
61261
|
if (!namedFlag) {
|
|
61234
61262
|
throw new AliasNotFoundError(aliasName);
|
|
61235
61263
|
}
|
|
61236
|
-
return
|
|
61264
|
+
return namedFlag;
|
|
61237
61265
|
});
|
|
61238
61266
|
}
|
|
61239
61267
|
const flagNameMatch = FLAG_NAME_PATTERN.exec(arg);
|
|
61240
61268
|
if (flagNameMatch) {
|
|
61241
61269
|
const externalFlagName = flagNameMatch[1];
|
|
61242
|
-
return [findInternalFlagMatch(externalFlagName, flags, config)];
|
|
61270
|
+
return [findInternalFlagMatch(externalFlagName, flags, allowsNegation, config)];
|
|
61243
61271
|
}
|
|
61244
61272
|
return [];
|
|
61245
61273
|
}
|
|
@@ -61254,16 +61282,16 @@ var InvalidNegatedFlagSyntaxError = class extends ArgumentScannerError {
|
|
|
61254
61282
|
this.valueText = valueText;
|
|
61255
61283
|
}
|
|
61256
61284
|
};
|
|
61257
|
-
function findFlagByArgumentWithInput(arg, flags, resolvedAliases, config) {
|
|
61285
|
+
function findFlagByArgumentWithInput(arg, flags, allowsNegation, resolvedAliases, config) {
|
|
61258
61286
|
const flagsNameMatch = FLAG_NAME_VALUE_PATTERN.exec(arg);
|
|
61259
61287
|
if (flagsNameMatch) {
|
|
61260
61288
|
const externalFlagName = flagsNameMatch[1];
|
|
61261
|
-
const
|
|
61289
|
+
const namedFlag = findInternalFlagMatch(externalFlagName, flags, allowsNegation, config);
|
|
61262
61290
|
const valueText = flagsNameMatch[2];
|
|
61263
|
-
if (
|
|
61291
|
+
if (namedFlag[2]) {
|
|
61264
61292
|
throw new InvalidNegatedFlagSyntaxError(externalFlagName, valueText);
|
|
61265
61293
|
}
|
|
61266
|
-
return [
|
|
61294
|
+
return [namedFlag, valueText];
|
|
61267
61295
|
}
|
|
61268
61296
|
const aliasValueMatch = ALIAS_VALUE_PATTERN.exec(arg);
|
|
61269
61297
|
if (aliasValueMatch) {
|
|
@@ -61395,6 +61423,7 @@ function isFlagSatisfiedByInputs(flags, flagInputs, key) {
|
|
|
61395
61423
|
}
|
|
61396
61424
|
function buildArgumentScanner(parameters, config) {
|
|
61397
61425
|
const { flags = {}, aliases = {}, positional = { kind: "tuple", parameters: [] } } = parameters;
|
|
61426
|
+
const allowsNegation = resolveAllowedNegationForFlags(flags);
|
|
61398
61427
|
const resolvedAliases = resolveAliases(flags, aliases, config.caseStyle);
|
|
61399
61428
|
const positionalInputs = [];
|
|
61400
61429
|
const flagInputs = /* @__PURE__ */ new Map;
|
|
@@ -61417,7 +61446,7 @@ function buildArgumentScanner(parameters, config) {
|
|
|
61417
61446
|
return;
|
|
61418
61447
|
}
|
|
61419
61448
|
if (!treatInputsAsArguments) {
|
|
61420
|
-
const flagInput = findFlagByArgumentWithInput(input, flags, resolvedAliases, config);
|
|
61449
|
+
const flagInput = findFlagByArgumentWithInput(input, flags, allowsNegation, resolvedAliases, config);
|
|
61421
61450
|
if (flagInput) {
|
|
61422
61451
|
if (activeFlag) {
|
|
61423
61452
|
if (activeFlag[1].kind === "parsed" && activeFlag[1].inferEmpty) {
|
|
@@ -61432,7 +61461,7 @@ function buildArgumentScanner(parameters, config) {
|
|
|
61432
61461
|
storeInput(flagInputs, config.caseStyle, ...flagInput);
|
|
61433
61462
|
return;
|
|
61434
61463
|
}
|
|
61435
|
-
const nextFlags = findFlagsByArgument(input, flags, resolvedAliases, config);
|
|
61464
|
+
const nextFlags = findFlagsByArgument(input, flags, allowsNegation, resolvedAliases, config);
|
|
61436
61465
|
if (nextFlags.length > 0) {
|
|
61437
61466
|
if (activeFlag) {
|
|
61438
61467
|
if (activeFlag[1].kind === "parsed" && activeFlag[1].inferEmpty) {
|
|
@@ -61440,24 +61469,24 @@ function buildArgumentScanner(parameters, config) {
|
|
|
61440
61469
|
activeFlag = undefined;
|
|
61441
61470
|
} else {
|
|
61442
61471
|
const externalFlagName = asExternal(activeFlag[0], config.caseStyle);
|
|
61443
|
-
const nextFlagName = asExternal(nextFlags[0]
|
|
61472
|
+
const nextFlagName = asExternal(nextFlags[0][0], config.caseStyle);
|
|
61444
61473
|
throw new UnsatisfiedFlagError(externalFlagName, nextFlagName);
|
|
61445
61474
|
}
|
|
61446
61475
|
}
|
|
61447
61476
|
if (nextFlags.every(isNiladic)) {
|
|
61448
61477
|
for (const nextFlag of nextFlags) {
|
|
61449
|
-
if (nextFlag
|
|
61450
|
-
storeInput(flagInputs, config.caseStyle, nextFlag
|
|
61478
|
+
if (nextFlag[1].kind === "boolean") {
|
|
61479
|
+
storeInput(flagInputs, config.caseStyle, nextFlag, nextFlag[2] ? "false" : "true");
|
|
61451
61480
|
} else {
|
|
61452
|
-
storeInput(flagInputs, config.caseStyle, nextFlag
|
|
61481
|
+
storeInput(flagInputs, config.caseStyle, nextFlag, "1");
|
|
61453
61482
|
}
|
|
61454
61483
|
}
|
|
61455
61484
|
} else if (nextFlags.length > 1) {
|
|
61456
61485
|
const nextFlagExpectingArg = nextFlags.find((nextFlag) => !isNiladic(nextFlag));
|
|
61457
|
-
const externalFlagName = asExternal(nextFlagExpectingArg
|
|
61486
|
+
const externalFlagName = asExternal(nextFlagExpectingArg[0], config.caseStyle);
|
|
61458
61487
|
throw new UnsatisfiedFlagError(externalFlagName);
|
|
61459
61488
|
} else {
|
|
61460
|
-
activeFlag = nextFlags[0]
|
|
61489
|
+
activeFlag = nextFlags[0];
|
|
61461
61490
|
}
|
|
61462
61491
|
return;
|
|
61463
61492
|
}
|
|
@@ -61546,7 +61575,7 @@ function buildArgumentScanner(parameters, config) {
|
|
|
61546
61575
|
const parsedFlags = Object.fromEntries(flagEntriesResult.value);
|
|
61547
61576
|
return { success: true, arguments: [parsedFlags, ...positionalValuesResult.value] };
|
|
61548
61577
|
},
|
|
61549
|
-
proposeCompletions: async ({ partial, completionConfig, text, context
|
|
61578
|
+
proposeCompletions: async ({ partial, completionConfig, text, context }) => {
|
|
61550
61579
|
if (activeFlag) {
|
|
61551
61580
|
return proposeFlagCompletionsForPartialInput(activeFlag[1], context, partial);
|
|
61552
61581
|
}
|
|
@@ -61568,12 +61597,6 @@ function buildArgumentScanner(parameters, config) {
|
|
|
61568
61597
|
}
|
|
61569
61598
|
} else if (shorthandMatch) {
|
|
61570
61599
|
const partialAliases = Array.from(shorthandMatch[1]);
|
|
61571
|
-
if (partialAliases.includes("h")) {
|
|
61572
|
-
return [];
|
|
61573
|
-
}
|
|
61574
|
-
if (includeVersionFlag && partialAliases.includes("v")) {
|
|
61575
|
-
return [];
|
|
61576
|
-
}
|
|
61577
61600
|
const flagInputsIncludingPartial = new Map(flagInputs);
|
|
61578
61601
|
for (const alias of partialAliases) {
|
|
61579
61602
|
const namedFlag = resolvedAliases[alias];
|
|
@@ -61696,80 +61719,13 @@ function listAllRouteNamesAndAliasesForScan(routeMap, scannerCaseStyle, config)
|
|
|
61696
61719
|
return [routeName];
|
|
61697
61720
|
});
|
|
61698
61721
|
}
|
|
61699
|
-
var text_en = {
|
|
61700
|
-
headers: {
|
|
61701
|
-
usage: "USAGE",
|
|
61702
|
-
aliases: "ALIASES",
|
|
61703
|
-
commands: "COMMANDS",
|
|
61704
|
-
flags: "FLAGS",
|
|
61705
|
-
arguments: "ARGUMENTS"
|
|
61706
|
-
},
|
|
61707
|
-
keywords: {
|
|
61708
|
-
default: "default =",
|
|
61709
|
-
separator: "separator ="
|
|
61710
|
-
},
|
|
61711
|
-
briefs: {
|
|
61712
|
-
help: "Print help information and exit",
|
|
61713
|
-
helpAll: "Print help information (including hidden commands/flags) and exit",
|
|
61714
|
-
version: "Print version information and exit",
|
|
61715
|
-
argumentEscapeSequence: "All subsequent inputs should be interpreted as arguments"
|
|
61716
|
-
},
|
|
61717
|
-
noCommandRegisteredForInput({ input, corrections }) {
|
|
61718
|
-
const errorMessage = `No command registered for \`${input}\``;
|
|
61719
|
-
if (corrections.length > 0) {
|
|
61720
|
-
const formattedCorrections = joinWithGrammar(corrections, {
|
|
61721
|
-
kind: "conjunctive",
|
|
61722
|
-
conjunction: "or",
|
|
61723
|
-
serialComma: true
|
|
61724
|
-
});
|
|
61725
|
-
return `${errorMessage}, did you mean ${formattedCorrections}?`;
|
|
61726
|
-
} else {
|
|
61727
|
-
return errorMessage;
|
|
61728
|
-
}
|
|
61729
|
-
},
|
|
61730
|
-
noTextAvailableForLocale({ requestedLocale, defaultLocale }) {
|
|
61731
|
-
return `Application does not support "${requestedLocale}" locale, defaulting to "${defaultLocale}"`;
|
|
61732
|
-
},
|
|
61733
|
-
exceptionWhileParsingArguments(exc) {
|
|
61734
|
-
if (exc instanceof ArgumentScannerError) {
|
|
61735
|
-
return formatMessageForArgumentScannerError(exc, {});
|
|
61736
|
-
}
|
|
61737
|
-
return `Unable to parse arguments, ${(this.formatException ?? formatException)(exc)}`;
|
|
61738
|
-
},
|
|
61739
|
-
exceptionWhileLoadingCommandFunction(exc) {
|
|
61740
|
-
return `Unable to load command function, ${(this.formatException ?? formatException)(exc)}`;
|
|
61741
|
-
},
|
|
61742
|
-
exceptionWhileLoadingCommandContext(exc) {
|
|
61743
|
-
return `Unable to load command context, ${(this.formatException ?? formatException)(exc)}`;
|
|
61744
|
-
},
|
|
61745
|
-
exceptionWhileRunningCommand(exc) {
|
|
61746
|
-
return `Command failed, ${(this.formatException ?? formatException)(exc)}`;
|
|
61747
|
-
},
|
|
61748
|
-
commandErrorResult(err) {
|
|
61749
|
-
return err.message;
|
|
61750
|
-
},
|
|
61751
|
-
currentVersionIsNotLatest({ currentVersion, latestVersion, upgradeCommand }) {
|
|
61752
|
-
if (upgradeCommand) {
|
|
61753
|
-
return `Latest available version is ${latestVersion} (currently running ${currentVersion}), upgrade with "${upgradeCommand}"`;
|
|
61754
|
-
}
|
|
61755
|
-
return `Latest available version is ${latestVersion} (currently running ${currentVersion})`;
|
|
61756
|
-
}
|
|
61757
|
-
};
|
|
61758
|
-
function defaultTextLoader(locale) {
|
|
61759
|
-
if (locale.startsWith("en")) {
|
|
61760
|
-
return text_en;
|
|
61761
|
-
}
|
|
61762
|
-
}
|
|
61763
|
-
function shouldUseAnsiColor(process2, stream, config) {
|
|
61764
|
-
return !config.disableAnsiColor && !checkEnvironmentVariable(process2, "STRICLI_NO_COLOR") && (stream.getColorDepth?.(process2.env) ?? 1) >= 4;
|
|
61765
|
-
}
|
|
61766
61722
|
async function runCommand({ loader, parameters }, {
|
|
61767
61723
|
context,
|
|
61768
61724
|
inputs,
|
|
61769
61725
|
scannerConfig,
|
|
61770
61726
|
errorFormatting,
|
|
61771
|
-
|
|
61772
|
-
|
|
61727
|
+
determineExitCode,
|
|
61728
|
+
ansiColorByStream
|
|
61773
61729
|
}) {
|
|
61774
61730
|
let parsedArguments;
|
|
61775
61731
|
try {
|
|
@@ -61781,19 +61737,17 @@ async function runCommand({ loader, parameters }, {
|
|
|
61781
61737
|
if (result.success) {
|
|
61782
61738
|
parsedArguments = result.arguments;
|
|
61783
61739
|
} else {
|
|
61784
|
-
const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
|
|
61785
61740
|
for (const error of result.errors) {
|
|
61786
|
-
const errorMessage = errorFormatting.exceptionWhileParsingArguments(error,
|
|
61787
|
-
context.process.stderr.write(
|
|
61741
|
+
const errorMessage = errorFormatting.exceptionWhileParsingArguments(error, ansiColorByStream.stderr);
|
|
61742
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61788
61743
|
` : `${errorMessage}
|
|
61789
61744
|
`);
|
|
61790
61745
|
}
|
|
61791
61746
|
return ExitCode.InvalidArgument;
|
|
61792
61747
|
}
|
|
61793
61748
|
} catch (exc) {
|
|
61794
|
-
const
|
|
61795
|
-
|
|
61796
|
-
context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61749
|
+
const errorMessage = errorFormatting.exceptionWhileParsingArguments(exc, ansiColorByStream.stderr);
|
|
61750
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61797
61751
|
` : `${errorMessage}
|
|
61798
61752
|
`);
|
|
61799
61753
|
return ExitCode.InvalidArgument;
|
|
@@ -61807,9 +61761,8 @@ async function runCommand({ loader, parameters }, {
|
|
|
61807
61761
|
commandFunction = loaded.default;
|
|
61808
61762
|
}
|
|
61809
61763
|
} catch (exc) {
|
|
61810
|
-
const
|
|
61811
|
-
|
|
61812
|
-
context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61764
|
+
const errorMessage = errorFormatting.exceptionWhileLoadingCommandFunction(exc, ansiColorByStream.stderr);
|
|
61765
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61813
61766
|
` : `${errorMessage}
|
|
61814
61767
|
`);
|
|
61815
61768
|
return ExitCode.CommandLoadError;
|
|
@@ -61817,9 +61770,8 @@ async function runCommand({ loader, parameters }, {
|
|
|
61817
61770
|
try {
|
|
61818
61771
|
const result = await commandFunction.call(context, ...parsedArguments);
|
|
61819
61772
|
if (result instanceof Error) {
|
|
61820
|
-
const
|
|
61821
|
-
|
|
61822
|
-
context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61773
|
+
const errorMessage = errorFormatting.commandErrorResult(result, ansiColorByStream.stderr);
|
|
61774
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61823
61775
|
` : `${errorMessage}
|
|
61824
61776
|
`);
|
|
61825
61777
|
if (determineExitCode) {
|
|
@@ -61828,9 +61780,8 @@ async function runCommand({ loader, parameters }, {
|
|
|
61828
61780
|
return ExitCode.CommandRunError;
|
|
61829
61781
|
}
|
|
61830
61782
|
} catch (exc) {
|
|
61831
|
-
const
|
|
61832
|
-
|
|
61833
|
-
context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61783
|
+
const errorMessage = errorFormatting.exceptionWhileRunningCommand(exc, ansiColorByStream.stderr);
|
|
61784
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61834
61785
|
` : `${errorMessage}
|
|
61835
61786
|
`);
|
|
61836
61787
|
if (determineExitCode) {
|
|
@@ -61842,14 +61793,26 @@ async function runCommand({ loader, parameters }, {
|
|
|
61842
61793
|
}
|
|
61843
61794
|
var RouteMapSymbol = Symbol("RouteMap");
|
|
61844
61795
|
var CommandSymbol = Symbol("Command");
|
|
61845
|
-
function buildRouteScanner(root, config, startingPrefix) {
|
|
61796
|
+
function buildRouteScanner(root, config, startingPrefix, additionalFlags) {
|
|
61846
61797
|
const prefix = [...startingPrefix];
|
|
61847
61798
|
const unprocessedInputs = [];
|
|
61799
|
+
const flags = {};
|
|
61800
|
+
for (const additionalFlag of additionalFlags) {
|
|
61801
|
+
flags[additionalFlag.name] = additionalFlag;
|
|
61802
|
+
}
|
|
61803
|
+
const aliases = {};
|
|
61804
|
+
for (const additionalFlag of additionalFlags) {
|
|
61805
|
+
if (additionalFlag.aliases) {
|
|
61806
|
+
for (const alias of additionalFlag.aliases) {
|
|
61807
|
+
aliases[alias] = additionalFlag.name;
|
|
61808
|
+
}
|
|
61809
|
+
}
|
|
61810
|
+
}
|
|
61811
|
+
const resolvedAliases = resolveAliases(flags, aliases, config.caseStyle);
|
|
61812
|
+
let activeFlag;
|
|
61848
61813
|
let parent;
|
|
61849
61814
|
let current = root;
|
|
61850
61815
|
let target;
|
|
61851
|
-
let rootLevel = true;
|
|
61852
|
-
let helpRequested = false;
|
|
61853
61816
|
let treatInputsAsArguments = false;
|
|
61854
61817
|
return {
|
|
61855
61818
|
next: (input) => {
|
|
@@ -61858,22 +61821,20 @@ function buildRouteScanner(root, config, startingPrefix) {
|
|
|
61858
61821
|
unprocessedInputs.push(input);
|
|
61859
61822
|
return;
|
|
61860
61823
|
}
|
|
61861
|
-
if (!treatInputsAsArguments) {
|
|
61862
|
-
|
|
61863
|
-
|
|
61864
|
-
|
|
61865
|
-
|
|
61866
|
-
|
|
61867
|
-
|
|
61868
|
-
|
|
61869
|
-
helpRequested = "all";
|
|
61870
|
-
if (!target) {
|
|
61824
|
+
if (!treatInputsAsArguments && !activeFlag) {
|
|
61825
|
+
try {
|
|
61826
|
+
const nextFlags = findFlagsByArgument(input, flags, {}, resolvedAliases, config);
|
|
61827
|
+
for (const currentFlag of nextFlags) {
|
|
61828
|
+
if (!currentFlag[1].global && current !== root) {
|
|
61829
|
+
continue;
|
|
61830
|
+
}
|
|
61831
|
+
activeFlag = currentFlag[1];
|
|
61871
61832
|
target = current;
|
|
61833
|
+
return;
|
|
61872
61834
|
}
|
|
61873
|
-
|
|
61874
|
-
}
|
|
61835
|
+
} catch {}
|
|
61875
61836
|
}
|
|
61876
|
-
if (target) {
|
|
61837
|
+
if (target || treatInputsAsArguments) {
|
|
61877
61838
|
unprocessedInputs.push(input);
|
|
61878
61839
|
return;
|
|
61879
61840
|
}
|
|
@@ -61893,123 +61854,413 @@ function buildRouteScanner(root, config, startingPrefix) {
|
|
|
61893
61854
|
}
|
|
61894
61855
|
if (!next) {
|
|
61895
61856
|
const defaultCommand = current.getDefaultCommand();
|
|
61857
|
+
unprocessedInputs.push(input);
|
|
61896
61858
|
if (defaultCommand) {
|
|
61897
|
-
rootLevel = false;
|
|
61898
61859
|
parent = [current, ""];
|
|
61899
|
-
unprocessedInputs.push(input);
|
|
61900
61860
|
current = defaultCommand;
|
|
61901
61861
|
return;
|
|
61902
61862
|
}
|
|
61903
61863
|
return { input, routeMap: current };
|
|
61904
61864
|
}
|
|
61905
|
-
rootLevel = false;
|
|
61906
61865
|
parent = [current, input];
|
|
61907
61866
|
current = next;
|
|
61908
61867
|
prefix.push(input);
|
|
61909
61868
|
},
|
|
61910
61869
|
finish: () => {
|
|
61911
61870
|
target = target ?? current;
|
|
61912
|
-
if (target.kind === RouteMapSymbol && !
|
|
61871
|
+
if (target.kind === RouteMapSymbol && !activeFlag) {
|
|
61913
61872
|
const defaultCommand = target.getDefaultCommand();
|
|
61914
61873
|
if (defaultCommand) {
|
|
61915
61874
|
parent = [target, ""];
|
|
61916
61875
|
target = defaultCommand;
|
|
61917
|
-
rootLevel = false;
|
|
61918
61876
|
}
|
|
61919
61877
|
}
|
|
61920
|
-
const
|
|
61878
|
+
const aliases2 = parent ? parent[0].getOtherAliasesForInput(parent[1], config.caseStyle) : { original: [], "convert-camel-to-kebab": [] };
|
|
61921
61879
|
return {
|
|
61922
61880
|
target,
|
|
61923
61881
|
unprocessedInputs,
|
|
61924
|
-
helpRequested,
|
|
61925
61882
|
prefix,
|
|
61926
|
-
|
|
61927
|
-
|
|
61883
|
+
aliases: aliases2,
|
|
61884
|
+
activeFlag
|
|
61928
61885
|
};
|
|
61929
61886
|
}
|
|
61930
61887
|
};
|
|
61931
61888
|
}
|
|
61932
|
-
|
|
61933
|
-
|
|
61934
|
-
|
|
61935
|
-
|
|
61936
|
-
|
|
61937
|
-
|
|
61938
|
-
|
|
61939
|
-
|
|
61940
|
-
|
|
61941
|
-
|
|
61942
|
-
|
|
61943
|
-
|
|
61889
|
+
function checkEnvironmentVariable(process2, varName) {
|
|
61890
|
+
const value = process2.env?.[varName];
|
|
61891
|
+
return typeof value === "string" && looseBooleanParser(value);
|
|
61892
|
+
}
|
|
61893
|
+
var text_en = {
|
|
61894
|
+
headers: {
|
|
61895
|
+
usage: "USAGE",
|
|
61896
|
+
aliases: "ALIASES",
|
|
61897
|
+
commands: "COMMANDS",
|
|
61898
|
+
flags: "FLAGS",
|
|
61899
|
+
arguments: "ARGUMENTS"
|
|
61900
|
+
},
|
|
61901
|
+
keywords: {
|
|
61902
|
+
default: "default =",
|
|
61903
|
+
separator: "separator ="
|
|
61904
|
+
},
|
|
61905
|
+
briefs: {
|
|
61906
|
+
help: "Print help information and exit",
|
|
61907
|
+
helpAll: "Print help information (including hidden commands/flags) and exit",
|
|
61908
|
+
version: "Print version information and exit",
|
|
61909
|
+
argumentEscapeSequence: "All subsequent inputs should be interpreted as arguments"
|
|
61910
|
+
},
|
|
61911
|
+
noCommandRegisteredForInput({ input, corrections }) {
|
|
61912
|
+
const errorMessage = `No command registered for \`${input}\``;
|
|
61913
|
+
if (corrections.length > 0) {
|
|
61914
|
+
const formattedCorrections = joinWithGrammar(corrections, {
|
|
61915
|
+
kind: "conjunctive",
|
|
61916
|
+
conjunction: "or",
|
|
61917
|
+
serialComma: true
|
|
61944
61918
|
});
|
|
61945
|
-
|
|
61919
|
+
return `${errorMessage}, did you mean ${formattedCorrections}?`;
|
|
61920
|
+
} else {
|
|
61921
|
+
return errorMessage;
|
|
61922
|
+
}
|
|
61923
|
+
},
|
|
61924
|
+
noTextAvailableForLocale({ requestedLocale, defaultLocale }) {
|
|
61925
|
+
return `Application does not support "${requestedLocale}" locale, defaulting to "${defaultLocale}"`;
|
|
61926
|
+
},
|
|
61927
|
+
exceptionWhileParsingArguments(exc) {
|
|
61928
|
+
if (exc instanceof ArgumentScannerError) {
|
|
61929
|
+
return formatMessageForArgumentScannerError(exc, {});
|
|
61930
|
+
}
|
|
61931
|
+
return `Unable to parse arguments, ${(this.formatException ?? formatException)(exc)}`;
|
|
61932
|
+
},
|
|
61933
|
+
exceptionWhileLoadingCommandFunction(exc) {
|
|
61934
|
+
return `Unable to load command function, ${(this.formatException ?? formatException)(exc)}`;
|
|
61935
|
+
},
|
|
61936
|
+
exceptionWhileLoadingCommandContext(exc) {
|
|
61937
|
+
return `Unable to load command context, ${(this.formatException ?? formatException)(exc)}`;
|
|
61938
|
+
},
|
|
61939
|
+
exceptionWhileRunningCommand(exc) {
|
|
61940
|
+
return `Command failed, ${(this.formatException ?? formatException)(exc)}`;
|
|
61941
|
+
},
|
|
61942
|
+
exceptionWhileRunningIntegrationHook({ exception, hook, integration }) {
|
|
61943
|
+
return `Unexpected exception thrown by '${integration}' integration during '${hook}' hook.
|
|
61944
|
+
${(this.formatException ?? formatException)(exception)}`;
|
|
61945
|
+
},
|
|
61946
|
+
exceptionWhileRunningIntegrationFlag({ exception, integration }) {
|
|
61947
|
+
return `Unexpected exception thrown by "--${integration}" flag from the '${integration}' integration.
|
|
61948
|
+
${(this.formatException ?? formatException)(exception)}`;
|
|
61949
|
+
},
|
|
61950
|
+
commandErrorResult(err) {
|
|
61951
|
+
return err.message;
|
|
61952
|
+
},
|
|
61953
|
+
currentVersionIsNotLatest({ currentVersion, latestVersion, upgradeCommand }) {
|
|
61954
|
+
if (upgradeCommand) {
|
|
61955
|
+
return `Latest available version is ${latestVersion} (currently running ${currentVersion}), upgrade with "${upgradeCommand}"`;
|
|
61956
|
+
}
|
|
61957
|
+
return `Latest available version is ${latestVersion} (currently running ${currentVersion})`;
|
|
61958
|
+
}
|
|
61959
|
+
};
|
|
61960
|
+
function defaultTextLoader(locale) {
|
|
61961
|
+
if (locale.startsWith("en")) {
|
|
61962
|
+
return text_en;
|
|
61963
|
+
}
|
|
61964
|
+
}
|
|
61965
|
+
function shouldUseAnsiColor(process2, stream, config) {
|
|
61966
|
+
return !config.disableAnsiColor && !checkEnvironmentVariable(process2, "STRICLI_NO_COLOR") && (stream.getColorDepth?.(process2.env) ?? 1) >= 4;
|
|
61967
|
+
}
|
|
61968
|
+
function shouldUseAnsiColorForStreams(process2, config) {
|
|
61969
|
+
return {
|
|
61970
|
+
stdout: shouldUseAnsiColor(process2, process2.stdout, config),
|
|
61971
|
+
stderr: shouldUseAnsiColor(process2, process2.stderr, config)
|
|
61972
|
+
};
|
|
61973
|
+
}
|
|
61974
|
+
function validateCaseStyleCompatibility(scan, display) {
|
|
61975
|
+
if (scan === "original" && display === "convert-camel-to-kebab") {
|
|
61976
|
+
throw new Error("Cannot convert route and flag names on display (convert-camel-to-kebab) but scan as original");
|
|
61977
|
+
}
|
|
61978
|
+
}
|
|
61979
|
+
function help({
|
|
61980
|
+
alias = "h",
|
|
61981
|
+
includeHidden = false,
|
|
61982
|
+
formatting,
|
|
61983
|
+
...config
|
|
61984
|
+
}) {
|
|
61985
|
+
return {
|
|
61986
|
+
validate(_root, config2) {
|
|
61987
|
+
validateCaseStyleCompatibility(config2.scanner.caseStyle, formatting.caseStyle);
|
|
61988
|
+
},
|
|
61989
|
+
flag: {
|
|
61990
|
+
...config,
|
|
61991
|
+
global: true,
|
|
61992
|
+
aliases: alias === false ? [] : [alias],
|
|
61993
|
+
async run(app, { text, ansiColorByStream, result, additionalFlags }) {
|
|
61994
|
+
this.process.stdout.write(result.target.formatHelp({
|
|
61995
|
+
prefix: result.prefix,
|
|
61996
|
+
additionalFlags,
|
|
61997
|
+
includeArgumentEscapeSequenceFlag: app.config.scanner.allowArgumentEscapeSequence,
|
|
61998
|
+
includeHidden,
|
|
61999
|
+
config: formatting,
|
|
62000
|
+
aliases: result.aliases[formatting.caseStyle],
|
|
62001
|
+
text,
|
|
62002
|
+
ansiColor: ansiColorByStream.stdout
|
|
62003
|
+
}));
|
|
62004
|
+
}
|
|
62005
|
+
}
|
|
62006
|
+
};
|
|
62007
|
+
}
|
|
62008
|
+
function version({
|
|
62009
|
+
info,
|
|
62010
|
+
alias = "v",
|
|
62011
|
+
hook = "app:start",
|
|
62012
|
+
...config
|
|
62013
|
+
}) {
|
|
62014
|
+
let versionCheck;
|
|
62015
|
+
if (info.getLatestVersion) {
|
|
62016
|
+
const getLatestVersion = info.getLatestVersion;
|
|
62017
|
+
versionCheck = async function({ text, ansiColorByStream }) {
|
|
62018
|
+
if (checkEnvironmentVariable(this.process, "STRICLI_SKIP_VERSION_CHECK")) {
|
|
62019
|
+
return;
|
|
62020
|
+
}
|
|
62021
|
+
let currentVersion;
|
|
62022
|
+
if ("currentVersion" in info) {
|
|
62023
|
+
currentVersion = info.currentVersion;
|
|
62024
|
+
} else {
|
|
62025
|
+
currentVersion = await info.getCurrentVersion.call(this);
|
|
62026
|
+
}
|
|
62027
|
+
const latestVersion = await getLatestVersion.call(this, currentVersion);
|
|
62028
|
+
if (latestVersion && currentVersion !== latestVersion) {
|
|
62029
|
+
const warningMessage = text.currentVersionIsNotLatest({
|
|
62030
|
+
currentVersion,
|
|
62031
|
+
latestVersion,
|
|
62032
|
+
upgradeCommand: info.upgradeCommand,
|
|
62033
|
+
ansiColor: ansiColorByStream.stderr
|
|
62034
|
+
});
|
|
62035
|
+
this.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
|
|
61946
62036
|
` : `${warningMessage}
|
|
61947
62037
|
`);
|
|
62038
|
+
}
|
|
62039
|
+
};
|
|
62040
|
+
}
|
|
62041
|
+
return {
|
|
62042
|
+
hooks: versionCheck ? { [hook]: versionCheck } : {},
|
|
62043
|
+
flag: {
|
|
62044
|
+
...config,
|
|
62045
|
+
defaultForRouteMap: false,
|
|
62046
|
+
global: false,
|
|
62047
|
+
aliases: alias === false ? [] : [alias],
|
|
62048
|
+
async run() {
|
|
62049
|
+
let currentVersion;
|
|
62050
|
+
if ("currentVersion" in info) {
|
|
62051
|
+
currentVersion = info.currentVersion;
|
|
62052
|
+
} else {
|
|
62053
|
+
currentVersion = await info.getCurrentVersion.call(this);
|
|
62054
|
+
}
|
|
62055
|
+
this.process.stdout.write(currentVersion + `
|
|
62056
|
+
`);
|
|
62057
|
+
}
|
|
62058
|
+
}
|
|
62059
|
+
};
|
|
62060
|
+
}
|
|
62061
|
+
async function runHook(integrations, hookName, context, args) {
|
|
62062
|
+
for (const [name, integration] of Object.entries(integrations)) {
|
|
62063
|
+
const hook = integration.hooks?.[hookName];
|
|
62064
|
+
if (hook) {
|
|
62065
|
+
try {
|
|
62066
|
+
await hook.call(context, args);
|
|
62067
|
+
} catch (exc) {
|
|
62068
|
+
const errorMessage = args.text.exceptionWhileRunningIntegrationHook({
|
|
62069
|
+
exception: exc,
|
|
62070
|
+
hook: hookName,
|
|
62071
|
+
integration: name,
|
|
62072
|
+
ansiColor: args.ansiColorByStream.stderr
|
|
62073
|
+
});
|
|
62074
|
+
context.process.stderr.write(args.ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
62075
|
+
` : `${errorMessage}
|
|
62076
|
+
`);
|
|
62077
|
+
return ExitCode.IntegrationError;
|
|
62078
|
+
}
|
|
62079
|
+
}
|
|
62080
|
+
}
|
|
62081
|
+
}
|
|
62082
|
+
function checkIntegrationsForCollisions(integrations, caseStyle) {
|
|
62083
|
+
let routeMapDefault;
|
|
62084
|
+
const flagNames = new Set(Object.keys(integrations));
|
|
62085
|
+
const aliases = /* @__PURE__ */ new Map;
|
|
62086
|
+
for (const [name, integration] of Object.entries(integrations)) {
|
|
62087
|
+
if (caseStyle === "allow-kebab-for-camel") {
|
|
62088
|
+
const camelCase = convertKebabCaseToCamelCase(name);
|
|
62089
|
+
if (camelCase !== name && flagNames.has(camelCase)) {
|
|
62090
|
+
throw new InternalError(`Multiple integrations are trying to use the same flag name (with 'allow-kebab-for-camel'): '${name}' and '${camelCase}'`);
|
|
62091
|
+
}
|
|
62092
|
+
}
|
|
62093
|
+
if (integration.flag) {
|
|
62094
|
+
if (integration.flag.defaultForRouteMap) {
|
|
62095
|
+
if (routeMapDefault) {
|
|
62096
|
+
throw new InternalError(`Multiple integrations provide a default flag for route maps: '${routeMapDefault}' and '${name}'`);
|
|
62097
|
+
}
|
|
62098
|
+
routeMapDefault = name;
|
|
62099
|
+
}
|
|
62100
|
+
for (const alias of integration.flag.aliases ?? []) {
|
|
62101
|
+
const flagForAlias = aliases.get(alias);
|
|
62102
|
+
if (flagForAlias) {
|
|
62103
|
+
throw new InternalError(`Multiple integrations are trying to use the same flag alias "-${alias}": '${flagForAlias}' and '${name}'`);
|
|
62104
|
+
}
|
|
62105
|
+
aliases.set(alias, name);
|
|
62106
|
+
}
|
|
61948
62107
|
}
|
|
61949
62108
|
}
|
|
61950
|
-
|
|
61951
|
-
|
|
61952
|
-
|
|
61953
|
-
|
|
62109
|
+
}
|
|
62110
|
+
function checkIntegrationsForFlagNameConflicts(root, additionalFlags, caseStyle) {
|
|
62111
|
+
function checkForConflicts(target, prefix) {
|
|
62112
|
+
if (target.kind === CommandSymbol) {
|
|
62113
|
+
const relevantFlags = root === target ? additionalFlags : additionalFlags.filter(({ global: global2 }) => global2);
|
|
62114
|
+
for (const { name, aliases } of relevantFlags) {
|
|
62115
|
+
if (target.usesFlag(name, caseStyle)) {
|
|
62116
|
+
throw new InternalError(`'${name}' integration provides a flag that would override: "${[...prefix, `--${name}`].join(" ")}"`);
|
|
62117
|
+
}
|
|
62118
|
+
for (const alias of aliases ?? []) {
|
|
62119
|
+
if (target.usesFlag(alias, caseStyle)) {
|
|
62120
|
+
throw new InternalError(`'${name}' integration provides a flag with an alias that would override: "${[...prefix, `-${alias}`].join(" ")}"`);
|
|
62121
|
+
}
|
|
62122
|
+
}
|
|
62123
|
+
}
|
|
61954
62124
|
} else {
|
|
61955
|
-
|
|
61956
|
-
|
|
61957
|
-
|
|
61958
|
-
|
|
61959
|
-
|
|
61960
|
-
|
|
61961
|
-
|
|
61962
|
-
|
|
61963
|
-
|
|
61964
|
-
|
|
62125
|
+
for (const entry of target.getAllEntries()) {
|
|
62126
|
+
checkForConflicts(entry.target, [...prefix, entry.name.original]);
|
|
62127
|
+
}
|
|
62128
|
+
}
|
|
62129
|
+
}
|
|
62130
|
+
checkForConflicts(root, []);
|
|
62131
|
+
}
|
|
62132
|
+
function gatherAdditionalFlagsFromIntegrations(integrations) {
|
|
62133
|
+
const flags = [];
|
|
62134
|
+
for (const [name, integration] of Object.entries(integrations)) {
|
|
62135
|
+
if (integration.flag) {
|
|
62136
|
+
flags.push({ ...integration.flag, name });
|
|
62137
|
+
}
|
|
62138
|
+
}
|
|
62139
|
+
return flags;
|
|
62140
|
+
}
|
|
62141
|
+
function validateIntegrations(integrations, root, config) {
|
|
62142
|
+
for (const [name, integration] of Object.entries(integrations)) {
|
|
62143
|
+
try {
|
|
62144
|
+
integration.validate?.(root, config);
|
|
62145
|
+
} catch (exc) {
|
|
62146
|
+
throw new InternalError(`Integration '${name}' failed validation: ${String(exc)}`, { cause: exc });
|
|
62147
|
+
}
|
|
62148
|
+
}
|
|
62149
|
+
}
|
|
62150
|
+
function gatherDefaultIntegrations(config, text) {
|
|
62151
|
+
const integrations = {
|
|
62152
|
+
help: help({
|
|
62153
|
+
brief: text.briefs.help,
|
|
62154
|
+
alias: "h",
|
|
62155
|
+
defaultForRouteMap: true,
|
|
62156
|
+
includeHidden: false,
|
|
62157
|
+
formatting: config.documentation
|
|
62158
|
+
}),
|
|
62159
|
+
helpAll: help({
|
|
62160
|
+
brief: text.briefs.helpAll,
|
|
62161
|
+
alias: "H",
|
|
62162
|
+
hidden: !config.documentation.alwaysShowHelpAllFlag,
|
|
62163
|
+
includeHidden: true,
|
|
62164
|
+
formatting: config.documentation
|
|
62165
|
+
})
|
|
62166
|
+
};
|
|
62167
|
+
if (config.versionInfo) {
|
|
62168
|
+
integrations["version"] = version({
|
|
62169
|
+
brief: text.briefs.version,
|
|
62170
|
+
info: config.versionInfo,
|
|
62171
|
+
alias: "v",
|
|
62172
|
+
hook: "app:start"
|
|
62173
|
+
});
|
|
62174
|
+
}
|
|
62175
|
+
return integrations;
|
|
62176
|
+
}
|
|
62177
|
+
async function runApplication(app, rawInputs, context) {
|
|
62178
|
+
const ansiColorByStream = shouldUseAnsiColorForStreams(context.process, app.config.documentation);
|
|
62179
|
+
let text = app.defaultText;
|
|
62180
|
+
if (context.locale && "loadText" in app.config.localization) {
|
|
62181
|
+
const localeText = app.config.localization.loadText(context.locale);
|
|
62182
|
+
if (localeText) {
|
|
62183
|
+
text = localeText;
|
|
62184
|
+
} else {
|
|
62185
|
+
const warningMessage = text.noTextAvailableForLocale({
|
|
62186
|
+
requestedLocale: context.locale,
|
|
62187
|
+
defaultLocale: app.config.localization.defaultLocale,
|
|
62188
|
+
ansiColor: ansiColorByStream.stderr
|
|
61965
62189
|
});
|
|
61966
|
-
context.process.stderr.write(
|
|
62190
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
|
|
61967
62191
|
` : `${warningMessage}
|
|
61968
62192
|
`);
|
|
61969
62193
|
}
|
|
61970
62194
|
}
|
|
61971
|
-
const
|
|
61972
|
-
|
|
61973
|
-
|
|
61974
|
-
|
|
61975
|
-
|
|
61976
|
-
|
|
61977
|
-
|
|
61978
|
-
|
|
61979
|
-
|
|
61980
|
-
|
|
61981
|
-
|
|
62195
|
+
const hookStartExitCode = await runHook(app.integrations, "app:start", context, {
|
|
62196
|
+
text,
|
|
62197
|
+
ansiColorByStream
|
|
62198
|
+
});
|
|
62199
|
+
if (typeof hookStartExitCode === "number") {
|
|
62200
|
+
return hookStartExitCode;
|
|
62201
|
+
}
|
|
62202
|
+
const exitCode = await scanInputsAndRunTarget(app, rawInputs, context, text, ansiColorByStream);
|
|
62203
|
+
const hookEndExitCode = await runHook(app.integrations, "app:end", context, {
|
|
62204
|
+
text,
|
|
62205
|
+
ansiColorByStream,
|
|
62206
|
+
exitCode
|
|
62207
|
+
});
|
|
62208
|
+
if (typeof hookEndExitCode === "number") {
|
|
62209
|
+
return hookEndExitCode;
|
|
61982
62210
|
}
|
|
61983
|
-
|
|
62211
|
+
return exitCode;
|
|
62212
|
+
}
|
|
62213
|
+
async function scanInputsAndRunTarget(app, rawInputs, context, text, ansiColorByStream) {
|
|
62214
|
+
const additionalFlags = gatherAdditionalFlagsFromIntegrations(app.integrations);
|
|
62215
|
+
const inputs = rawInputs.slice();
|
|
62216
|
+
const scanner = buildRouteScanner(app.root, app.config.scanner, [app.config.name], additionalFlags);
|
|
61984
62217
|
let error;
|
|
61985
62218
|
while (inputs.length > 0 && !error) {
|
|
61986
62219
|
const arg = inputs.shift();
|
|
61987
62220
|
error = scanner.next(arg);
|
|
61988
62221
|
}
|
|
61989
62222
|
if (error) {
|
|
61990
|
-
const routeNames = listAllRouteNamesAndAliasesForScan(error.routeMap, config.scanner.caseStyle, config.completion);
|
|
61991
|
-
const corrections = filterClosestAlternatives(error.input, routeNames, config.scanner.distanceOptions).map((str) => `\`${str}\``);
|
|
61992
|
-
const
|
|
61993
|
-
|
|
61994
|
-
|
|
62223
|
+
const routeNames = listAllRouteNamesAndAliasesForScan(error.routeMap, app.config.scanner.caseStyle, app.config.completion);
|
|
62224
|
+
const corrections = filterClosestAlternatives(error.input, routeNames, app.config.scanner.distanceOptions).map((str) => `\`${str}\``);
|
|
62225
|
+
const errorMessage = text.noCommandRegisteredForInput({
|
|
62226
|
+
input: error.input,
|
|
62227
|
+
corrections,
|
|
62228
|
+
ansiColor: ansiColorByStream.stderr
|
|
62229
|
+
});
|
|
62230
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
61995
62231
|
` : `${errorMessage}
|
|
61996
62232
|
`);
|
|
61997
62233
|
return ExitCode.UnknownCommand;
|
|
61998
62234
|
}
|
|
61999
|
-
|
|
62000
|
-
if (
|
|
62001
|
-
|
|
62002
|
-
|
|
62003
|
-
|
|
62004
|
-
|
|
62005
|
-
|
|
62006
|
-
|
|
62007
|
-
|
|
62008
|
-
|
|
62009
|
-
|
|
62010
|
-
|
|
62011
|
-
|
|
62012
|
-
|
|
62235
|
+
let { activeFlag, ...result } = scanner.finish();
|
|
62236
|
+
if (activeFlag || result.target.kind === RouteMapSymbol) {
|
|
62237
|
+
if (!activeFlag) {
|
|
62238
|
+
activeFlag = additionalFlags.find((flag) => flag.defaultForRouteMap);
|
|
62239
|
+
}
|
|
62240
|
+
if (activeFlag) {
|
|
62241
|
+
let additionalFlagsForTarget = additionalFlags;
|
|
62242
|
+
if (result.target !== app.root) {
|
|
62243
|
+
additionalFlagsForTarget = additionalFlagsForTarget.filter((flag) => flag.global);
|
|
62244
|
+
}
|
|
62245
|
+
try {
|
|
62246
|
+
await activeFlag.run.call(context, app, {
|
|
62247
|
+
text,
|
|
62248
|
+
ansiColorByStream,
|
|
62249
|
+
result,
|
|
62250
|
+
additionalFlags: additionalFlagsForTarget
|
|
62251
|
+
});
|
|
62252
|
+
} catch (exc) {
|
|
62253
|
+
const errorMessage = text.exceptionWhileRunningIntegrationFlag({
|
|
62254
|
+
exception: exc,
|
|
62255
|
+
ansiColor: ansiColorByStream.stderr,
|
|
62256
|
+
integration: activeFlag.name
|
|
62257
|
+
});
|
|
62258
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
|
|
62259
|
+
` : `${errorMessage}
|
|
62260
|
+
`);
|
|
62261
|
+
return ExitCode.IntegrationError;
|
|
62262
|
+
}
|
|
62263
|
+
}
|
|
62013
62264
|
return ExitCode.Success;
|
|
62014
62265
|
}
|
|
62015
62266
|
let commandContext;
|
|
@@ -62017,117 +62268,62 @@ async function runApplication({ root, defaultText, config }, rawInputs, context)
|
|
|
62017
62268
|
try {
|
|
62018
62269
|
commandContext = await context.forCommand({ prefix: result.prefix });
|
|
62019
62270
|
} catch (exc) {
|
|
62020
|
-
const
|
|
62021
|
-
|
|
62022
|
-
context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m` : errorMessage);
|
|
62271
|
+
const errorMessage = text.exceptionWhileLoadingCommandContext(exc, ansiColorByStream.stderr);
|
|
62272
|
+
context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m` : errorMessage);
|
|
62023
62273
|
return ExitCode.ContextLoadError;
|
|
62024
62274
|
}
|
|
62025
62275
|
} else {
|
|
62026
62276
|
commandContext = context;
|
|
62027
62277
|
}
|
|
62028
|
-
|
|
62278
|
+
const hookStartExitCode = await runHook(app.integrations, "command:start", commandContext, {
|
|
62279
|
+
text,
|
|
62280
|
+
ansiColorByStream,
|
|
62281
|
+
result
|
|
62282
|
+
});
|
|
62283
|
+
if (typeof hookStartExitCode === "number") {
|
|
62284
|
+
return hookStartExitCode;
|
|
62285
|
+
}
|
|
62286
|
+
const exitCode = await runCommand(result.target, {
|
|
62029
62287
|
context: commandContext,
|
|
62030
62288
|
inputs: result.unprocessedInputs,
|
|
62031
|
-
scannerConfig: config.scanner,
|
|
62032
|
-
documentationConfig: config.documentation,
|
|
62289
|
+
scannerConfig: app.config.scanner,
|
|
62033
62290
|
errorFormatting: text,
|
|
62034
|
-
determineExitCode: config.determineExitCode
|
|
62291
|
+
determineExitCode: app.config.determineExitCode,
|
|
62292
|
+
ansiColorByStream
|
|
62035
62293
|
});
|
|
62036
|
-
|
|
62037
|
-
|
|
62038
|
-
|
|
62039
|
-
|
|
62294
|
+
const hookEndExitCode = await runHook(app.integrations, "command:end", commandContext, {
|
|
62295
|
+
text,
|
|
62296
|
+
ansiColorByStream,
|
|
62297
|
+
result,
|
|
62298
|
+
exitCode
|
|
62299
|
+
});
|
|
62300
|
+
if (typeof hookEndExitCode === "number") {
|
|
62301
|
+
return hookEndExitCode;
|
|
62040
62302
|
}
|
|
62041
|
-
return
|
|
62303
|
+
return exitCode;
|
|
62042
62304
|
}
|
|
62043
|
-
function
|
|
62044
|
-
|
|
62045
|
-
return `no-${convertCamelCaseToKebabCase(flagName)}`;
|
|
62046
|
-
}
|
|
62047
|
-
return `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
|
|
62305
|
+
function hasDefault(flag) {
|
|
62306
|
+
return "default" in flag && typeof flag.default !== "undefined";
|
|
62048
62307
|
}
|
|
62049
|
-
function
|
|
62050
|
-
|
|
62308
|
+
function isOptionalAtRuntime(flag) {
|
|
62309
|
+
return flag.optional ?? hasDefault(flag);
|
|
62310
|
+
}
|
|
62311
|
+
function withDefaultFormattingConfiguration(config, scannerCaseStyle) {
|
|
62051
62312
|
let displayCaseStyle;
|
|
62052
|
-
if (config.
|
|
62053
|
-
|
|
62054
|
-
throw new InternalError("Cannot convert route and flag names on display but scan as original");
|
|
62055
|
-
}
|
|
62056
|
-
displayCaseStyle = config.documentation.caseStyle;
|
|
62313
|
+
if (config.caseStyle) {
|
|
62314
|
+
displayCaseStyle = config.caseStyle;
|
|
62057
62315
|
} else if (scannerCaseStyle === "allow-kebab-for-camel") {
|
|
62058
62316
|
displayCaseStyle = "convert-camel-to-kebab";
|
|
62059
62317
|
} else {
|
|
62060
62318
|
displayCaseStyle = scannerCaseStyle;
|
|
62061
62319
|
}
|
|
62062
|
-
|
|
62063
|
-
caseStyle: scannerCaseStyle,
|
|
62064
|
-
allowArgumentEscapeSequence: config.scanner?.allowArgumentEscapeSequence ?? false,
|
|
62065
|
-
distanceOptions: config.scanner?.distanceOptions ?? {
|
|
62066
|
-
threshold: 7,
|
|
62067
|
-
weights: {
|
|
62068
|
-
insertion: 1,
|
|
62069
|
-
deletion: 3,
|
|
62070
|
-
substitution: 2,
|
|
62071
|
-
transposition: 0
|
|
62072
|
-
}
|
|
62073
|
-
}
|
|
62074
|
-
};
|
|
62075
|
-
const documentationConfig = {
|
|
62076
|
-
alwaysShowHelpAllFlag: config.documentation?.alwaysShowHelpAllFlag ?? false,
|
|
62077
|
-
useAliasInUsageLine: config.documentation?.useAliasInUsageLine ?? false,
|
|
62078
|
-
onlyRequiredInUsageLine: config.documentation?.onlyRequiredInUsageLine ?? false,
|
|
62079
|
-
caseStyle: displayCaseStyle,
|
|
62080
|
-
disableAnsiColor: config.documentation?.disableAnsiColor ?? false
|
|
62081
|
-
};
|
|
62082
|
-
const completionConfig = {
|
|
62083
|
-
includeAliases: config.completion?.includeAliases ?? documentationConfig.useAliasInUsageLine,
|
|
62084
|
-
includeHiddenRoutes: config.completion?.includeHiddenRoutes ?? false,
|
|
62085
|
-
...config.completion
|
|
62086
|
-
};
|
|
62320
|
+
validateCaseStyleCompatibility(scannerCaseStyle, displayCaseStyle);
|
|
62087
62321
|
return {
|
|
62088
|
-
|
|
62089
|
-
|
|
62090
|
-
|
|
62091
|
-
documentation: documentationConfig,
|
|
62092
|
-
localization: {
|
|
62093
|
-
defaultLocale: "en",
|
|
62094
|
-
loadText: defaultTextLoader,
|
|
62095
|
-
...config.localization
|
|
62096
|
-
}
|
|
62322
|
+
useAliasInUsageLine: config.useAliasInUsageLine ?? false,
|
|
62323
|
+
onlyRequiredInUsageLine: config.onlyRequiredInUsageLine ?? false,
|
|
62324
|
+
caseStyle: displayCaseStyle
|
|
62097
62325
|
};
|
|
62098
62326
|
}
|
|
62099
|
-
function buildApplication(root, appConfig) {
|
|
62100
|
-
const config = withDefaults(appConfig);
|
|
62101
|
-
if (root.kind === CommandSymbol && config.versionInfo) {
|
|
62102
|
-
if (root.usesFlag("version")) {
|
|
62103
|
-
throw new InternalError("Unable to use command with flag --version as root when version info is supplied");
|
|
62104
|
-
}
|
|
62105
|
-
if (root.usesFlag("v")) {
|
|
62106
|
-
throw new InternalError("Unable to use command with alias -v as root when version info is supplied");
|
|
62107
|
-
}
|
|
62108
|
-
}
|
|
62109
|
-
let defaultText;
|
|
62110
|
-
if ("text" in config.localization) {
|
|
62111
|
-
defaultText = config.localization.text;
|
|
62112
|
-
} else {
|
|
62113
|
-
const text = config.localization.loadText(config.localization.defaultLocale);
|
|
62114
|
-
if (!text) {
|
|
62115
|
-
throw new InternalError(`No text available for the default locale "${config.localization.defaultLocale}"`);
|
|
62116
|
-
}
|
|
62117
|
-
defaultText = text;
|
|
62118
|
-
}
|
|
62119
|
-
return {
|
|
62120
|
-
root,
|
|
62121
|
-
config,
|
|
62122
|
-
defaultText
|
|
62123
|
-
};
|
|
62124
|
-
}
|
|
62125
|
-
function hasDefault(flag) {
|
|
62126
|
-
return "default" in flag && typeof flag.default !== "undefined";
|
|
62127
|
-
}
|
|
62128
|
-
function isOptionalAtRuntime(flag) {
|
|
62129
|
-
return flag.optional ?? hasDefault(flag);
|
|
62130
|
-
}
|
|
62131
62327
|
function wrapRequiredFlag(text) {
|
|
62132
62328
|
return `(${text})`;
|
|
62133
62329
|
}
|
|
@@ -62201,8 +62397,92 @@ function formatUsageLineForParameters(parameters, args) {
|
|
|
62201
62397
|
}
|
|
62202
62398
|
return [...args.prefix, ...flagsUsage, ...positionalUsage].join(" ");
|
|
62203
62399
|
}
|
|
62400
|
+
function formatForDisplay(flagName, displayCaseStyle) {
|
|
62401
|
+
if (displayCaseStyle === "convert-camel-to-kebab") {
|
|
62402
|
+
return convertCamelCaseToKebabCase(flagName);
|
|
62403
|
+
}
|
|
62404
|
+
return flagName;
|
|
62405
|
+
}
|
|
62406
|
+
function formatAsNegated(flagName, displayCaseStyle) {
|
|
62407
|
+
if (displayCaseStyle === "convert-camel-to-kebab") {
|
|
62408
|
+
return `no-${convertCamelCaseToKebabCase(flagName)}`;
|
|
62409
|
+
}
|
|
62410
|
+
return `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
|
|
62411
|
+
}
|
|
62412
|
+
function withDefaults(config) {
|
|
62413
|
+
const scannerCaseStyle = config.scanner?.caseStyle ?? "original";
|
|
62414
|
+
const scannerConfig = {
|
|
62415
|
+
caseStyle: scannerCaseStyle,
|
|
62416
|
+
allowArgumentEscapeSequence: config.scanner?.allowArgumentEscapeSequence ?? false,
|
|
62417
|
+
distanceOptions: config.scanner?.distanceOptions ?? {
|
|
62418
|
+
threshold: 7,
|
|
62419
|
+
weights: {
|
|
62420
|
+
insertion: 1,
|
|
62421
|
+
deletion: 3,
|
|
62422
|
+
substitution: 2,
|
|
62423
|
+
transposition: 0
|
|
62424
|
+
}
|
|
62425
|
+
}
|
|
62426
|
+
};
|
|
62427
|
+
const documentationConfig = {
|
|
62428
|
+
alwaysShowHelpAllFlag: config.documentation?.alwaysShowHelpAllFlag ?? false,
|
|
62429
|
+
disableAnsiColor: config.documentation?.disableAnsiColor ?? false,
|
|
62430
|
+
...withDefaultFormattingConfiguration(config.documentation ?? {}, scannerCaseStyle)
|
|
62431
|
+
};
|
|
62432
|
+
const completionConfig = {
|
|
62433
|
+
includeAliases: config.completion?.includeAliases ?? documentationConfig.useAliasInUsageLine,
|
|
62434
|
+
includeHiddenRoutes: config.completion?.includeHiddenRoutes ?? false,
|
|
62435
|
+
...config.completion
|
|
62436
|
+
};
|
|
62437
|
+
return {
|
|
62438
|
+
...config,
|
|
62439
|
+
scanner: scannerConfig,
|
|
62440
|
+
completion: completionConfig,
|
|
62441
|
+
documentation: documentationConfig,
|
|
62442
|
+
localization: {
|
|
62443
|
+
defaultLocale: "en",
|
|
62444
|
+
loadText: defaultTextLoader,
|
|
62445
|
+
...config.localization
|
|
62446
|
+
}
|
|
62447
|
+
};
|
|
62448
|
+
}
|
|
62449
|
+
function buildApplication(root, appConfig, integrations) {
|
|
62450
|
+
const config = withDefaults(appConfig);
|
|
62451
|
+
let defaultText;
|
|
62452
|
+
if ("text" in config.localization) {
|
|
62453
|
+
defaultText = config.localization.text;
|
|
62454
|
+
} else {
|
|
62455
|
+
const text = config.localization.loadText(config.localization.defaultLocale);
|
|
62456
|
+
if (!text) {
|
|
62457
|
+
throw new InternalError(`No text available for the default locale "${config.localization.defaultLocale}"`);
|
|
62458
|
+
}
|
|
62459
|
+
defaultText = text;
|
|
62460
|
+
}
|
|
62461
|
+
if (integrations) {
|
|
62462
|
+
checkIntegrationsForCollisions(integrations, config.scanner.caseStyle);
|
|
62463
|
+
} else {
|
|
62464
|
+
integrations = gatherDefaultIntegrations(config, defaultText);
|
|
62465
|
+
}
|
|
62466
|
+
const additionalFlags = gatherAdditionalFlagsFromIntegrations(integrations);
|
|
62467
|
+
checkIntegrationsForFlagNameConflicts(root, additionalFlags, config.scanner.caseStyle);
|
|
62468
|
+
validateIntegrations(integrations, root, config);
|
|
62469
|
+
return {
|
|
62470
|
+
root,
|
|
62471
|
+
config,
|
|
62472
|
+
defaultText,
|
|
62473
|
+
integrations
|
|
62474
|
+
};
|
|
62475
|
+
}
|
|
62476
|
+
function formatRowForAdditionalFlag(flag, caseStyle) {
|
|
62477
|
+
return {
|
|
62478
|
+
aliases: flag.aliases ? flag.aliases.map((alias) => `-${alias}`).join(" ") : "",
|
|
62479
|
+
flagName: `--${formatForDisplay(flag.name, caseStyle)}`,
|
|
62480
|
+
brief: flag.brief,
|
|
62481
|
+
hidden: flag.hidden
|
|
62482
|
+
};
|
|
62483
|
+
}
|
|
62204
62484
|
function formatDocumentationForFlagParameters(flags, aliases, args) {
|
|
62205
|
-
const { keywords
|
|
62485
|
+
const { keywords } = args.text;
|
|
62206
62486
|
const visibleFlags = Object.entries(flags).filter(([, flag]) => {
|
|
62207
62487
|
if (flag.hidden && !args.includeHidden) {
|
|
62208
62488
|
return false;
|
|
@@ -62258,32 +62538,21 @@ function formatDocumentationForFlagParameters(flags, aliases, args) {
|
|
|
62258
62538
|
hidden: flag.hidden
|
|
62259
62539
|
};
|
|
62260
62540
|
});
|
|
62261
|
-
|
|
62262
|
-
|
|
62263
|
-
|
|
62264
|
-
|
|
62265
|
-
|
|
62266
|
-
if (args.includeHelpAllFlag) {
|
|
62267
|
-
const helpAllFlagName = formatForDisplay("helpAll", args.config.caseStyle);
|
|
62268
|
-
rows.push({
|
|
62269
|
-
aliases: "-H",
|
|
62270
|
-
flagName: atLeastOneOptional ? ` --${helpAllFlagName}` : `--${helpAllFlagName}`,
|
|
62271
|
-
brief: briefs.helpAll,
|
|
62272
|
-
hidden: !args.config.alwaysShowHelpAllFlag
|
|
62273
|
-
});
|
|
62274
|
-
}
|
|
62275
|
-
if (args.includeVersionFlag) {
|
|
62541
|
+
for (const flag of args.additionalFlags) {
|
|
62542
|
+
if (flag.hidden && !args.includeHidden) {
|
|
62543
|
+
continue;
|
|
62544
|
+
}
|
|
62545
|
+
const row = formatRowForAdditionalFlag(flag, args.config.caseStyle);
|
|
62276
62546
|
rows.push({
|
|
62277
|
-
|
|
62278
|
-
flagName: atLeastOneOptional ?
|
|
62279
|
-
brief: briefs.version
|
|
62547
|
+
...row,
|
|
62548
|
+
flagName: atLeastOneOptional ? ` ${row.flagName}` : row.flagName
|
|
62280
62549
|
});
|
|
62281
62550
|
}
|
|
62282
62551
|
if (args.includeArgumentEscapeSequenceFlag) {
|
|
62283
62552
|
rows.push({
|
|
62284
62553
|
aliases: "",
|
|
62285
62554
|
flagName: atLeastOneOptional ? " --" : "--",
|
|
62286
|
-
brief: briefs.argumentEscapeSequence
|
|
62555
|
+
brief: args.text.briefs.argumentEscapeSequence
|
|
62287
62556
|
});
|
|
62288
62557
|
}
|
|
62289
62558
|
return formatRowsWithColumns(rows.map((row) => {
|
|
@@ -62298,14 +62567,16 @@ function formatDocumentationForFlagParameters(flags, aliases, args) {
|
|
|
62298
62567
|
];
|
|
62299
62568
|
}), [" ", " ", " "]);
|
|
62300
62569
|
}
|
|
62301
|
-
function*
|
|
62302
|
-
|
|
62303
|
-
|
|
62304
|
-
|
|
62305
|
-
|
|
62306
|
-
|
|
62307
|
-
|
|
62308
|
-
|
|
62570
|
+
function* generateUsageLinesForAdditionalFlags(flags, includeHidden, caseStyle, useAliasInUsageLine) {
|
|
62571
|
+
for (const flag of flags) {
|
|
62572
|
+
if (flag.hidden && !includeHidden) {
|
|
62573
|
+
continue;
|
|
62574
|
+
}
|
|
62575
|
+
if (useAliasInUsageLine && flag.aliases && flag.aliases.length > 0) {
|
|
62576
|
+
yield `-${flag.aliases[0]}`;
|
|
62577
|
+
} else {
|
|
62578
|
+
yield `--${formatForDisplay(flag.name, caseStyle)}`;
|
|
62579
|
+
}
|
|
62309
62580
|
}
|
|
62310
62581
|
}
|
|
62311
62582
|
function formatDocumentationForPositionalParameters(positional, args) {
|
|
@@ -62354,7 +62625,7 @@ function* generateCommandHelpLines(parameters, docs, args) {
|
|
|
62354
62625
|
} else {
|
|
62355
62626
|
yield ` ${formatUsageLineForParameters(parameters, args)}`;
|
|
62356
62627
|
}
|
|
62357
|
-
for (const line of
|
|
62628
|
+
for (const line of generateUsageLinesForAdditionalFlags(args.additionalFlags, args.includeHidden, args.config.caseStyle, args.config.useAliasInUsageLine)) {
|
|
62358
62629
|
yield ` ${prefix} ${line}`;
|
|
62359
62630
|
}
|
|
62360
62631
|
yield "";
|
|
@@ -62381,20 +62652,6 @@ function* generateCommandHelpLines(parameters, docs, args) {
|
|
|
62381
62652
|
}
|
|
62382
62653
|
}
|
|
62383
62654
|
}
|
|
62384
|
-
function checkForReservedFlags(flags, reserved) {
|
|
62385
|
-
for (const flag of reserved) {
|
|
62386
|
-
if (flag in flags) {
|
|
62387
|
-
throw new InternalError(`Unable to use reserved flag --${flag}`);
|
|
62388
|
-
}
|
|
62389
|
-
}
|
|
62390
|
-
}
|
|
62391
|
-
function checkForReservedAliases(aliases, reserved) {
|
|
62392
|
-
for (const alias of reserved) {
|
|
62393
|
-
if (alias in aliases) {
|
|
62394
|
-
throw new InternalError(`Unable to use reserved alias -${alias}`);
|
|
62395
|
-
}
|
|
62396
|
-
}
|
|
62397
|
-
}
|
|
62398
62655
|
function* asNegationFlagNames(flagName) {
|
|
62399
62656
|
yield `no-${convertCamelCaseToKebabCase(flagName)}`;
|
|
62400
62657
|
yield `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
|
|
@@ -62423,8 +62680,6 @@ function checkForInvalidVariadicSeparators(flags) {
|
|
|
62423
62680
|
}
|
|
62424
62681
|
function buildCommand(builderArgs) {
|
|
62425
62682
|
const { flags = {}, aliases = {} } = builderArgs.parameters;
|
|
62426
|
-
checkForReservedFlags(flags, ["help", "helpAll", "help-all"]);
|
|
62427
|
-
checkForReservedAliases(aliases, ["h", "H"]);
|
|
62428
62683
|
checkForNegationCollisions(flags);
|
|
62429
62684
|
checkForInvalidVariadicSeparators(flags);
|
|
62430
62685
|
let loader;
|
|
@@ -62455,7 +62710,13 @@ function buildCommand(builderArgs) {
|
|
|
62455
62710
|
return text + `
|
|
62456
62711
|
`;
|
|
62457
62712
|
},
|
|
62458
|
-
usesFlag: (flagName) => {
|
|
62713
|
+
usesFlag: (flagName, caseStyle) => {
|
|
62714
|
+
if (caseStyle === "allow-kebab-for-camel") {
|
|
62715
|
+
const kebabCase = convertCamelCaseToKebabCase(flagName);
|
|
62716
|
+
if (kebabCase in flags) {
|
|
62717
|
+
return true;
|
|
62718
|
+
}
|
|
62719
|
+
}
|
|
62459
62720
|
return Boolean(flagName in flags || flagName in aliases);
|
|
62460
62721
|
}
|
|
62461
62722
|
};
|
|
@@ -62474,7 +62735,7 @@ function* generateRouteMapHelpLines(routes, docs, args) {
|
|
|
62474
62735
|
}
|
|
62475
62736
|
}
|
|
62476
62737
|
const prefix = args.prefix.join(" ");
|
|
62477
|
-
for (const line of
|
|
62738
|
+
for (const line of generateUsageLinesForAdditionalFlags(args.additionalFlags, args.includeHidden, args.config.caseStyle, args.config.useAliasInUsageLine)) {
|
|
62478
62739
|
yield ` ${prefix} ${line}`;
|
|
62479
62740
|
}
|
|
62480
62741
|
yield "";
|
|
@@ -62529,14 +62790,14 @@ function buildRouteMap({
|
|
|
62529
62790
|
const aliasesByRoute = /* @__PURE__ */ new Map;
|
|
62530
62791
|
for (const [alias, routeName] of Object.entries(activeAliases)) {
|
|
62531
62792
|
if (alias in routes) {
|
|
62532
|
-
throw new InternalError(`Cannot use
|
|
62793
|
+
throw new InternalError(`Cannot use '${alias}' as an alias when a route with that name already exists`);
|
|
62533
62794
|
}
|
|
62534
62795
|
const routeAliases = aliasesByRoute.get(routeName) ?? [];
|
|
62535
62796
|
aliasesByRoute.set(routeName, [...routeAliases, alias]);
|
|
62536
62797
|
}
|
|
62537
62798
|
const defaultCommand = defaultCommandRoute ? routes[defaultCommandRoute] : undefined;
|
|
62538
62799
|
if (defaultCommand && defaultCommand.kind === RouteMapSymbol) {
|
|
62539
|
-
throw new InternalError(`Cannot use
|
|
62800
|
+
throw new InternalError(`Cannot use '${defaultCommandRoute}' as the default command because it is not a Command`);
|
|
62540
62801
|
}
|
|
62541
62802
|
const resolveRouteName = (input) => {
|
|
62542
62803
|
if (input in activeAliases) {
|
|
@@ -62557,8 +62818,8 @@ function buildRouteMap({
|
|
|
62557
62818
|
const routeNames = this.getAllEntries().filter((entry) => !entry.hidden).map((entry) => entry.name[args.config.caseStyle]);
|
|
62558
62819
|
return `${args.prefix.join(" ")} ${routeNames.join("|")} ...`;
|
|
62559
62820
|
},
|
|
62560
|
-
formatHelp: (
|
|
62561
|
-
const lines = [...generateRouteMapHelpLines(routes, docs,
|
|
62821
|
+
formatHelp: (args) => {
|
|
62822
|
+
const lines = [...generateRouteMapHelpLines(routes, docs, args)];
|
|
62562
62823
|
const text = lines.join(`
|
|
62563
62824
|
`);
|
|
62564
62825
|
return text + `
|
|
@@ -62851,7 +63112,7 @@ var routes = buildRouteMap({
|
|
|
62851
63112
|
var app = buildApplication(routes, {
|
|
62852
63113
|
name: "mcp",
|
|
62853
63114
|
versionInfo: {
|
|
62854
|
-
currentVersion: "0.0.
|
|
63115
|
+
currentVersion: "0.0.32"
|
|
62855
63116
|
}
|
|
62856
63117
|
});
|
|
62857
63118
|
run(app, process4.argv.slice(2), buildContext(process4));
|
|
@@ -62859,5 +63120,5 @@ export {
|
|
|
62859
63120
|
app
|
|
62860
63121
|
};
|
|
62861
63122
|
|
|
62862
|
-
//# debugId=
|
|
63123
|
+
//# debugId=7F1742DC6DB66A7464756E2164756E21
|
|
62863
63124
|
//# sourceMappingURL=mcp-server.js.map
|