@hardfin/cli 0.1.1-dev.75 → 0.1.1-dev.77
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0e61ba79-b67a-56d5-a2fd-a7a450bc463c")}catch(e){}}();
|
|
4
4
|
import { a as defineCommand, i as GLOBAL_FLAGS, r as ExitCode, t as toInvocation } from "./scrub-BZ0egWxC.js";
|
|
5
5
|
import { C as Interrupted, S as ExpectedFailure, T as TimedOut, _ as ConfigFailure, a as isShipped, b as toTelemetry, g as CONFIG_FILE, h as writeFailure, i as toUpdateCheckRefusal, l as toStateDirectory, m as writeData, o as toPackageDirectory, p as toText, r as toCheck, s as noteNotices, t as PACKAGE, u as isJSONOutput, v as toSettings, w as LockHeld, x as version$1, y as API_VERSION } from "./check-8Ta7vSnU.js";
|
|
6
6
|
import { n as toAnswer$1, r as toCompletion, t as PATH_VALUES } from "./completion-tree-DLC6ARLR.js";
|
|
@@ -1125,7 +1125,8 @@ function toTaken(flag) {
|
|
|
1125
1125
|
return flag.valueName ?? "nothing";
|
|
1126
1126
|
}
|
|
1127
1127
|
async function runAgentGuide(input) {
|
|
1128
|
-
const
|
|
1128
|
+
const words = input.args.flatMap((arg) => arg.split(/\s+/)).filter((word) => word.length > 0);
|
|
1129
|
+
const found = toNamed(input.commands, words);
|
|
1129
1130
|
if (found === void 0) {
|
|
1130
1131
|
writeFailure("invalid_arguments", `no command is called ${input.args.join(" ")}. Run hardfin --help for the list`, input.isJSON);
|
|
1131
1132
|
return ExitCode.USAGE;
|
|
@@ -1254,6 +1255,9 @@ function toHelpDescription(flag) {
|
|
|
1254
1255
|
function toProgram(root, command, onRun, isSilent) {
|
|
1255
1256
|
const program = new Command(command.name).summary(command.summary).description(command.description ?? command.summary);
|
|
1256
1257
|
toQuietParser(program, isSilent);
|
|
1258
|
+
program.exitOverride((error) => {
|
|
1259
|
+
throw toSuggested(error, command);
|
|
1260
|
+
});
|
|
1257
1261
|
for (const argument of command.arguments) {
|
|
1258
1262
|
const name = argument.variadic ? `${argument.name}...` : argument.name;
|
|
1259
1263
|
program.argument(argument.required ? `<${name}>` : `[${name}]`, argument.description);
|
|
@@ -1299,6 +1303,32 @@ function toQuietParser(program, isSilent) {
|
|
|
1299
1303
|
writeErr: () => void 0
|
|
1300
1304
|
});
|
|
1301
1305
|
}
|
|
1306
|
+
/** The most flags an unknown flag's error suggests. */
|
|
1307
|
+
const MAX_SUGGESTIONS = 3;
|
|
1308
|
+
/**
|
|
1309
|
+
* toSuggested names the flags an unknown flag may have meant, when the parser's own spelling
|
|
1310
|
+
* check found none, by matching the words of its name.
|
|
1311
|
+
*/
|
|
1312
|
+
function toSuggested(error, command) {
|
|
1313
|
+
const unknown = /unknown option '--([^']+)'/.exec(error.message)?.[1];
|
|
1314
|
+
if (error.code !== "commander.unknownOption" || unknown === void 0 || error.message.includes("Did you mean")) return error;
|
|
1315
|
+
const words = toWords(unknown);
|
|
1316
|
+
const matches = command.flags.map((flag) => ({
|
|
1317
|
+
name: flag.name,
|
|
1318
|
+
words: toWords(flag.name)
|
|
1319
|
+
})).filter((flag) => words.every((word) => flag.words.some((other) => isSameWord(word, other)))).sort((a, b) => a.words.length - b.words.length || a.name.localeCompare(b.name)).slice(0, MAX_SUGGESTIONS).map((flag) => `--${flag.name}`);
|
|
1320
|
+
if (matches.length === 0) return error;
|
|
1321
|
+
const suggestion = matches.length === 1 ? matches[0] : `one of ${matches.join(", ")}`;
|
|
1322
|
+
return new CommanderError(error.exitCode, error.code, `${error.message}\n(Did you mean ${suggestion}?)`);
|
|
1323
|
+
}
|
|
1324
|
+
function toWords(name) {
|
|
1325
|
+
return name.split("-").filter((word) => word.length > 0);
|
|
1326
|
+
}
|
|
1327
|
+
/** isSameWord treats a word and its plural, such as status and statuses, as one. */
|
|
1328
|
+
function isSameWord(given, other) {
|
|
1329
|
+
const [shorter, longer] = given.length <= other.length ? [given, other] : [other, given];
|
|
1330
|
+
return longer.startsWith(shorter) && longer.length - shorter.length <= 2;
|
|
1331
|
+
}
|
|
1302
1332
|
function toArgumentList(value) {
|
|
1303
1333
|
if (Array.isArray(value)) return value.map(String);
|
|
1304
1334
|
return value === void 0 ? [] : [toText(value)];
|
|
@@ -9546,7 +9576,7 @@ const surfaceCommands = [
|
|
|
9546
9576
|
{
|
|
9547
9577
|
name: "address",
|
|
9548
9578
|
jsonPath: ["address"],
|
|
9549
|
-
description: "The site's structured address. Takes only null, which clears it",
|
|
9579
|
+
description: "The site's structured address, which a zone refuses. Takes only null, which clears it",
|
|
9550
9580
|
valueName: "null",
|
|
9551
9581
|
nullable: true,
|
|
9552
9582
|
schema: z.null()
|
|
@@ -9610,7 +9640,7 @@ const surfaceCommands = [
|
|
|
9610
9640
|
{
|
|
9611
9641
|
name: "consignee",
|
|
9612
9642
|
jsonPath: ["consignee"],
|
|
9613
|
-
description: "The ID of the customer a zone is designated for, such as for reservations, provisioning or a 3PL",
|
|
9643
|
+
description: "The ID of the customer a zone is designated for, such as for reservations, provisioning or a 3PL, which a site refuses",
|
|
9614
9644
|
valueName: "uuid",
|
|
9615
9645
|
nullable: true,
|
|
9616
9646
|
schema: z.uuid()
|
|
@@ -9618,7 +9648,7 @@ const surfaceCommands = [
|
|
|
9618
9648
|
{
|
|
9619
9649
|
name: "customer-id",
|
|
9620
9650
|
jsonPath: ["customerId"],
|
|
9621
|
-
description: "The ID of the customer to assign a site to, or null for your organization's own site",
|
|
9651
|
+
description: "The ID of the customer to assign a site to, or null for your organization's own site, which a zone refuses",
|
|
9622
9652
|
valueName: "uuid",
|
|
9623
9653
|
nullable: true,
|
|
9624
9654
|
schema: z.uuid()
|
|
@@ -9626,7 +9656,7 @@ const surfaceCommands = [
|
|
|
9626
9656
|
{
|
|
9627
9657
|
name: "description",
|
|
9628
9658
|
jsonPath: ["description"],
|
|
9629
|
-
description: "A free-form description of a zone",
|
|
9659
|
+
description: "A free-form description of a zone, which a site refuses",
|
|
9630
9660
|
valueName: "value",
|
|
9631
9661
|
nullable: true,
|
|
9632
9662
|
schema: z.string()
|
|
@@ -9648,7 +9678,7 @@ const surfaceCommands = [
|
|
|
9648
9678
|
{
|
|
9649
9679
|
name: "is-transient",
|
|
9650
9680
|
jsonPath: ["isTransient"],
|
|
9651
|
-
description: "Whether assets make only occasional or temporary stops at the location, which hides it from location lists by default",
|
|
9681
|
+
description: "Whether assets make only occasional or temporary stops at the location, which hides it from location lists by default, and which a zone refuses",
|
|
9652
9682
|
negatable: true,
|
|
9653
9683
|
schema: z.boolean()
|
|
9654
9684
|
},
|
|
@@ -14483,5 +14513,5 @@ async function toReported(error, isJSON, resolved, level = "error") {
|
|
|
14483
14513
|
//#endregion
|
|
14484
14514
|
export { toCli, toParseExitCode, toReported, wasReportAttempted, writeCrash };
|
|
14485
14515
|
|
|
14486
|
-
//# sourceMappingURL=program-
|
|
14487
|
-
//# debugId=
|
|
14516
|
+
//# sourceMappingURL=program-CTAOEcIl.js.map
|
|
14517
|
+
//# debugId=0e61ba79-b67a-56d5-a2fd-a7a450bc463c
|