spec-controller 0.1.0-alpha.4 → 0.1.0-alpha.40
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/README.md +34 -6
- package/dist/cli-allocate/cli.d.ts +2 -0
- package/dist/cli-allocate/cli.d.ts.map +1 -0
- package/dist/cli-allocate/cli.js +57 -0
- package/dist/cli-allocate/cli.js.map +1 -0
- package/dist/cli-allocate/readHistory.d.ts +29 -0
- package/dist/cli-allocate/readHistory.d.ts.map +1 -0
- package/dist/cli-allocate/readHistory.js +136 -0
- package/dist/cli-allocate/readHistory.js.map +1 -0
- package/dist/cli-allocate/readParts.d.ts +3 -0
- package/dist/cli-allocate/readParts.d.ts.map +1 -0
- package/dist/cli-allocate/readParts.js +28 -0
- package/dist/cli-allocate/readParts.js.map +1 -0
- package/dist/cli-allocate/readTree.d.ts +16 -0
- package/dist/cli-allocate/readTree.d.ts.map +1 -0
- package/dist/cli-allocate/readTree.js +106 -0
- package/dist/cli-allocate/readTree.js.map +1 -0
- package/dist/cli-allocate/refStore.d.ts +3 -0
- package/dist/cli-allocate/refStore.d.ts.map +1 -0
- package/dist/cli-allocate/refStore.js +47 -0
- package/dist/cli-allocate/refStore.js.map +1 -0
- package/dist/cli-allocate/request.d.ts +11 -0
- package/dist/cli-allocate/request.d.ts.map +1 -0
- package/dist/cli-allocate/request.js +29 -0
- package/dist/cli-allocate/request.js.map +1 -0
- package/dist/cli-allocate/stderr.d.ts +14 -0
- package/dist/cli-allocate/stderr.d.ts.map +1 -0
- package/dist/cli-allocate/stderr.js +33 -0
- package/dist/cli-allocate/stderr.js.map +1 -0
- package/dist/cli-allocate/unreadable.d.ts +24 -0
- package/dist/cli-allocate/unreadable.d.ts.map +1 -0
- package/dist/cli-allocate/unreadable.js +43 -0
- package/dist/cli-allocate/unreadable.js.map +1 -0
- package/dist/cli-args.d.ts +73 -18
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +244 -22
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-balance/cli.d.ts +31 -13
- package/dist/cli-balance/cli.d.ts.map +1 -1
- package/dist/cli-balance/cli.js +205 -251
- package/dist/cli-balance/cli.js.map +1 -1
- package/dist/cli-balance/emit/writer.d.ts +8 -23
- package/dist/cli-balance/emit/writer.d.ts.map +1 -1
- package/dist/cli-balance/emit/writer.js +24 -32
- package/dist/cli-balance/emit/writer.js.map +1 -1
- package/dist/cli-balance/exitStatus.d.ts +3 -0
- package/dist/cli-balance/exitStatus.d.ts.map +1 -0
- package/dist/cli-balance/exitStatus.js +12 -0
- package/dist/cli-balance/exitStatus.js.map +1 -0
- package/dist/cli-balance/reRender.d.ts +22 -0
- package/dist/cli-balance/reRender.d.ts.map +1 -0
- package/dist/cli-balance/reRender.js +36 -0
- package/dist/cli-balance/reRender.js.map +1 -0
- package/dist/cli-balance/unreadableInputs.d.ts +35 -0
- package/dist/cli-balance/unreadableInputs.d.ts.map +1 -0
- package/dist/cli-balance/unreadableInputs.js +101 -0
- package/dist/cli-balance/unreadableInputs.js.map +1 -0
- package/dist/cli-registry.d.ts +28 -0
- package/dist/cli-registry.d.ts.map +1 -1
- package/dist/cli-registry.js +40 -35
- package/dist/cli-registry.js.map +1 -1
- package/dist/cli.d.ts +4 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +37 -21
- package/dist/cli.js.map +1 -1
- package/dist/host.d.ts +28 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +137 -17
- package/dist/host.js.map +1 -1
- package/dist/ingest/gherkinValidation.d.ts +3 -7
- package/dist/ingest/gherkinValidation.d.ts.map +1 -1
- package/dist/ingest/gherkinValidation.js +3 -7
- package/dist/ingest/gherkinValidation.js.map +1 -1
- package/dist/ingest/ingestQualityChecks.d.ts +25 -54
- package/dist/ingest/ingestQualityChecks.d.ts.map +1 -1
- package/dist/ingest/ingestQualityChecks.js +112 -145
- package/dist/ingest/ingestQualityChecks.js.map +1 -1
- package/dist/ingest/ingestScenarios.d.ts +11 -17
- package/dist/ingest/ingestScenarios.d.ts.map +1 -1
- package/dist/ingest/ingestScenarios.js +52 -62
- package/dist/ingest/ingestScenarios.js.map +1 -1
- package/dist/ingest/inputShapes.d.ts +47 -0
- package/dist/ingest/inputShapes.d.ts.map +1 -0
- package/dist/ingest/inputShapes.js +143 -0
- package/dist/ingest/inputShapes.js.map +1 -0
- package/dist/outputLocation.d.ts +15 -0
- package/dist/outputLocation.d.ts.map +1 -0
- package/dist/outputLocation.js +39 -0
- package/dist/outputLocation.js.map +1 -0
- package/dist/run-management/keptRun.d.ts +27 -25
- package/dist/run-management/keptRun.d.ts.map +1 -1
- package/dist/run-management/keptRun.js +20 -21
- package/dist/run-management/keptRun.js.map +1 -1
- package/dist/storedRun.d.ts +27 -0
- package/dist/storedRun.d.ts.map +1 -0
- package/dist/storedRun.js +49 -0
- package/dist/storedRun.js.map +1 -0
- package/package.json +2 -2
- package/dist/corpus/cli.d.ts +0 -34
- package/dist/corpus/cli.d.ts.map +0 -1
- package/dist/corpus/cli.js +0 -128
- package/dist/corpus/cli.js.map +0 -1
- package/dist/mutation-ratchet/index.d.ts +0 -51
- package/dist/mutation-ratchet/index.d.ts.map +0 -1
- package/dist/mutation-ratchet/index.js +0 -51
- package/dist/mutation-ratchet/index.js.map +0 -1
- package/dist/mutation-ratchet/record.d.ts +0 -178
- package/dist/mutation-ratchet/record.d.ts.map +0 -1
- package/dist/mutation-ratchet/record.js +0 -314
- package/dist/mutation-ratchet/record.js.map +0 -1
- package/dist/mutation-ratchet/report.d.ts +0 -109
- package/dist/mutation-ratchet/report.d.ts.map +0 -1
- package/dist/mutation-ratchet/report.js +0 -156
- package/dist/mutation-ratchet/report.js.map +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an `allocate` invocation asks for, read against the command's registry scope, or the usage
|
|
3
|
+
* error it is. A usage error is worded as one, so it is never taken for an unknown part.
|
|
4
|
+
*/
|
|
5
|
+
import { isFeaturePart } from "@3f-consulting/spec-controller-core";
|
|
6
|
+
import { checkArgvShape, checkMisplacedHostModifiers, checkUnknownFlags, parseArgs, positionalArguments, } from "../cli-args.js";
|
|
7
|
+
/** The request `argv` makes, or the usage error it is, worded for stderr. */
|
|
8
|
+
export function readRequest(argv, registry, toolVersion) {
|
|
9
|
+
const why = argvRefusal(argv, registry, toolVersion) ?? partRefusal(positionalArguments(argv, registry, "allocate")[0]);
|
|
10
|
+
if (why !== null)
|
|
11
|
+
return { usageError: `spec-controller allocate: usage error — ${why}` };
|
|
12
|
+
return { part: positionalArguments(argv, registry, "allocate")[0] ?? "", isNew: argv.includes("--new") };
|
|
13
|
+
}
|
|
14
|
+
/** The first refusal the argv earns against the registry, the same checks `balance` makes, in its order. */
|
|
15
|
+
function argvRefusal(argv, registry, toolVersion) {
|
|
16
|
+
const args = parseArgs(argv);
|
|
17
|
+
return (checkMisplacedHostModifiers(args, registry, "allocate") ??
|
|
18
|
+
checkArgvShape(argv, registry, "allocate") ??
|
|
19
|
+
checkUnknownFlags(args, registry, "allocate", toolVersion));
|
|
20
|
+
}
|
|
21
|
+
/** The refusal for the part given, or null when it is a feature part in canon's form. */
|
|
22
|
+
function partRefusal(part) {
|
|
23
|
+
if (part === undefined)
|
|
24
|
+
return "no feature part was given: 'spec-controller allocate <FFF>' takes one, a feature file's header code.";
|
|
25
|
+
if (isFeaturePart(part))
|
|
26
|
+
return null;
|
|
27
|
+
return `'${part}' is not a feature part in canon's form: two to five characters, each A-Z or 0-9.`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/cli-allocate/request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EACL,cAAc,EACd,2BAA2B,EAC3B,iBAAiB,EACjB,SAAS,EACT,mBAAmB,GAC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
|
|
4
|
+
import { type Allocation, type UnknownPart } from "@3f-consulting/spec-controller-core";
|
|
5
|
+
import type { HistoryBoundary } from "./readHistory.js";
|
|
6
|
+
/** What was left unread, and what that means for the answer; nothing when history was read whole. */
|
|
7
|
+
export declare function historyBoundaryLine(boundary: HistoryBoundary, allocation: Allocation): string | null;
|
|
8
|
+
/** Where the highest code was seen: a file and line, and the commit when only history carries it. */
|
|
9
|
+
export declare function highestSeenLine(allocation: Allocation): string;
|
|
10
|
+
/** The refusal for a part no feature file's header carries: the part, and the parts that are. */
|
|
11
|
+
export declare function unknownPartRefusal(refusal: UnknownPart): string;
|
|
12
|
+
/** The note for a part asked for as new that a header already carries; nothing otherwise. */
|
|
13
|
+
export declare function alreadyHeadedNote(allocation: Allocation): string | null;
|
|
14
|
+
//# sourceMappingURL=stderr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stderr.d.ts","sourceRoot":"","sources":["../../src/cli-allocate/stderr.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAiB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACvG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,qGAAqG;AACrG,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAKpG;AAED,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,CAK9D;AAED,iGAAiG;AACjG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAM/D;AAED,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAGvE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the allocator says beside its answer, on stderr, so stdout carries the code alone.
|
|
3
|
+
*/
|
|
4
|
+
import { featureCodeOf } from "@3f-consulting/spec-controller-core";
|
|
5
|
+
/** What was left unread, and what that means for the answer; nothing when history was read whole. */
|
|
6
|
+
export function historyBoundaryLine(boundary, allocation) {
|
|
7
|
+
if (boundary.kind === "complete")
|
|
8
|
+
return null;
|
|
9
|
+
const unread = boundary.kind === "shallow" ? `shallow clone — history before ${boundary.before} unread` : "not a git repository — none read";
|
|
10
|
+
const risk = allocation.highest === null ? `a code of ${featureCodeOf(allocation.code) ?? ""}` : `a code above ${allocation.highest.code}`;
|
|
11
|
+
return `history: ${unread}; ${risk} may have been used before`;
|
|
12
|
+
}
|
|
13
|
+
/** Where the highest code was seen: a file and line, and the commit when only history carries it. */
|
|
14
|
+
export function highestSeenLine(allocation) {
|
|
15
|
+
const highest = allocation.highest;
|
|
16
|
+
if (highest === null)
|
|
17
|
+
return "highest seen: none";
|
|
18
|
+
const { path, line, commit } = highest.sighting;
|
|
19
|
+
return `highest seen: ${highest.code}, ${path}:${line}${commit === undefined ? "" : ` in ${commit}`}`;
|
|
20
|
+
}
|
|
21
|
+
/** The refusal for a part no feature file's header carries: the part, and the parts that are. */
|
|
22
|
+
export function unknownPartRefusal(refusal) {
|
|
23
|
+
const parts = refusal.headerCodes.length === 0 ? "none" : refusal.headerCodes.join(", ");
|
|
24
|
+
return (`spec-controller allocate: unknown part — no feature file's header carries ${refusal.part}.\n` +
|
|
25
|
+
`The parts this corpus's feature files carry: ${parts}.`);
|
|
26
|
+
}
|
|
27
|
+
/** The note for a part asked for as new that a header already carries; nothing otherwise. */
|
|
28
|
+
export function alreadyHeadedNote(allocation) {
|
|
29
|
+
if (allocation.alreadyHeaded !== true)
|
|
30
|
+
return null;
|
|
31
|
+
return `note: a feature file's header already carries ${featureCodeOf(allocation.code) ?? ""}, so --new was not needed`;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=stderr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"st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AAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzF,OAAO,CACL,6EAA6E,OAAO,CAAC,IAAI,KAAK;QAC9F,gDAAgD,KAAK,GAAG,CACzD,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAAC,UAAsB;IACtD,IAAI,UAAU,CAAC,aAAa,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,iDAAiD,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,2BAA2B,CAAC;AAC1H,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path allocate is meant to read and cannot. It is the invocation being wrong, the same as a
|
|
3
|
+
* malformed request, so it is refused as a usage error naming the path and the reason, and no code
|
|
4
|
+
* is given: an answer computed without the path could hand out a code the unread path carries.
|
|
5
|
+
*/
|
|
6
|
+
/** What allocate could not read: which input it was, where (when the read had a path), and the reason. */
|
|
7
|
+
export declare class UnreadableInput extends Error {
|
|
8
|
+
readonly subject: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly reason: string;
|
|
11
|
+
readonly name = "UnreadableInput";
|
|
12
|
+
constructor(subject: string, path: string, reason: string);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The read's answer, or the refusal when the operating system refuses it. Any refusal the OS gives
|
|
16
|
+
* is the same fault here: not permitted, not the kind of path the read expects, or not there. A
|
|
17
|
+
* throw that carries no OS code is not a read failing, and is left to surface.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readOrRefuse<T>(subject: string, path: string, read: () => T): T;
|
|
20
|
+
/** Throw the refusal a failed read of `path` is, or the throw itself when it is not a read failing. */
|
|
21
|
+
export declare function refuse(subject: string, path: string, err: unknown): never;
|
|
22
|
+
/** The one stderr line a refusal is written as, in allocate's usage-error form. */
|
|
23
|
+
export declare function refusalLine(refusal: UnreadableInput): string;
|
|
24
|
+
//# sourceMappingURL=unreadable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unreadable.d.ts","sourceRoot":"","sources":["../../src/cli-allocate/unreadable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0GAA0G;AAC1G,qBAAa,eAAgB,SAAQ,KAAK;IAItC,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IALzB,SAAkB,IAAI,qBAAqB;gBAGhC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAI1B;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAM/E;AAED,uGAAuG;AACvG,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,KAAK,CAIzE;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path allocate is meant to read and cannot. It is the invocation being wrong, the same as a
|
|
3
|
+
* malformed request, so it is refused as a usage error naming the path and the reason, and no code
|
|
4
|
+
* is given: an answer computed without the path could hand out a code the unread path carries.
|
|
5
|
+
*/
|
|
6
|
+
/** What allocate could not read: which input it was, where (when the read had a path), and the reason. */
|
|
7
|
+
export class UnreadableInput extends Error {
|
|
8
|
+
subject;
|
|
9
|
+
path;
|
|
10
|
+
reason;
|
|
11
|
+
name = "UnreadableInput";
|
|
12
|
+
constructor(subject, path, reason) {
|
|
13
|
+
super(path === "" ? `${subject} could not be read (${reason})` : `${subject} could not be read: ${path} (${reason})`);
|
|
14
|
+
this.subject = subject;
|
|
15
|
+
this.path = path;
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The read's answer, or the refusal when the operating system refuses it. Any refusal the OS gives
|
|
21
|
+
* is the same fault here: not permitted, not the kind of path the read expects, or not there. A
|
|
22
|
+
* throw that carries no OS code is not a read failing, and is left to surface.
|
|
23
|
+
*/
|
|
24
|
+
export function readOrRefuse(subject, path, read) {
|
|
25
|
+
try {
|
|
26
|
+
return read();
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return refuse(subject, path, err);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Throw the refusal a failed read of `path` is, or the throw itself when it is not a read failing. */
|
|
33
|
+
export function refuse(subject, path, err) {
|
|
34
|
+
const errno = err;
|
|
35
|
+
if (!(err instanceof Error) || typeof errno.code !== "string")
|
|
36
|
+
throw err;
|
|
37
|
+
throw new UnreadableInput(subject, errno.path ?? path, err.message);
|
|
38
|
+
}
|
|
39
|
+
/** The one stderr line a refusal is written as, in allocate's usage-error form. */
|
|
40
|
+
export function refusalLine(refusal) {
|
|
41
|
+
return `spec-controller allocate: usage error — ${refusal.message}`;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=unreadable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unreadable.js","sourceRoot":"","sources":["../../src/cli-allocate/unreadable.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,0GAA0G;AAC1G,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAI7B;IACA;IACA;IALO,IAAI,GAAG,iBAAiB,CAAC;IAE3C,YACW,OAAe,EACf,IAAY,EACZ,MAAc;QAEvB,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,OAAO,uBAAuB,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,OAAO,uBAAuB,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC;QAJ7G,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;IAGzB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAI,OAAe,EAAE,IAAY,EAAE,IAAa;IAC1E,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,MAAM,CAAC,OAAe,EAAE,IAAY,EAAE,GAAY;IAChE,MAAM,KAAK,GAAG,GAA4B,CAAC;IAC3C,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAAE,MAAM,GAAG,CAAC;IACzE,MAAM,IAAI,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACtE,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,OAAO,2CAA2C,OAAO,CAAC,OAAO,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/cli-args.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THE ONE READING OF A COMMAND'S ARGV, and the one bounding of it against the registry.
|
|
3
3
|
*
|
|
4
|
-
* WHY IT IS ITS OWN MODULE
|
|
4
|
+
* WHY IT IS ITS OWN MODULE. Both halves lived inside `cli-balance/cli.ts` while
|
|
5
5
|
* `balance` was the only command — `parseArgs` private to it, `checkUnknownFlags` exported for
|
|
6
6
|
* its own `@unit` arm. A second command needs both, and the two ways of giving it them were
|
|
7
7
|
* worse than moving them: copying `parseArgs` would put a second reading of argv in a tree whose
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
* THE BOUNDING IS PER-COMMAND, which is what makes "accepted = registry = help" hold for every
|
|
13
13
|
* command rather than for the one this code was written beside. `checkUnknownFlags` took the
|
|
14
14
|
* registry and looked `balance` up inside itself; the command is a parameter now, exactly as it
|
|
15
|
-
* became one for `renderCommandHelp
|
|
16
|
-
* asks about `balance`:
|
|
17
|
-
* residual — that an unregistered flag to `tags` is unproven by a scenario of its own — is named
|
|
18
|
-
* on 3F-3286 rather than left silent.
|
|
15
|
+
* became one for `renderCommandHelp`. The unknown-flag scenario is unchanged and still
|
|
16
|
+
* asks about `balance`: a command added later gets the same bounding BY CONSTRUCTION.
|
|
19
17
|
*/
|
|
20
|
-
import type { CliRegistry } from "./cli-registry.js";
|
|
18
|
+
import type { CliRegistry, FlagSpec } from "./cli-registry.js";
|
|
19
|
+
/** True when a command's argv asks for its help, wherever `--help` or `-h` stands in it. */
|
|
20
|
+
export declare function asksForHelp(argv: readonly string[]): boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Parse `--flag value` pairs from a command's argv into a record, keys with the `--` stripped.
|
|
23
23
|
*
|
|
@@ -25,33 +25,85 @@ import type { CliRegistry } from "./cli-registry.js";
|
|
|
25
25
|
* the boolean flags — `--strict`, `--help` — are recognised: presence is what matters, so callers
|
|
26
26
|
* read them with `!== undefined`.
|
|
27
27
|
*
|
|
28
|
-
* PERMISSIVE BY ITSELF, AND BOUNDED BY THE CALLER. It records whatever it is given
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
28
|
+
* PERMISSIVE BY ITSELF, AND BOUNDED BY THE CALLER. It records whatever it is given — a flag no
|
|
29
|
+
* registry names, the last of two copies, a word after a flag that takes none — and drops a word
|
|
30
|
+
* that follows no flag. `checkArgvShape` and `checkUnknownFlags` below are what refuse those, before
|
|
31
|
+
* anything reads the record. The split is deliberate — the parse has no opinion about which
|
|
32
|
+
* command it is reading for, and the bounding has nothing else to do.
|
|
32
33
|
*/
|
|
33
34
|
export declare function parseArgs(argv: readonly string[]): Record<string, string>;
|
|
34
35
|
/**
|
|
35
|
-
* The
|
|
36
|
+
* The value flags of one scope: every flag the registry gives a value placeholder (`arg`), by
|
|
37
|
+
* name and alias, dashes kept. Read from the registry alone, so a value flag added later is one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function valueFlagsOf(flags: readonly FlagSpec[]): Map<string, FlagSpec>;
|
|
40
|
+
/**
|
|
41
|
+
* True when the token after a value flag is not a value: there is none, it is the next flag (the
|
|
42
|
+
* same `--` test `parseArgs` reads a flag by), or it is empty — an unset variable, quoted.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isMissingValue(next: string | undefined): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A flag that takes a value, given none, is a usage fault. It reads the
|
|
47
|
+
* RAW argv, because `parseArgs` has already turned a missing value into the string "true" — which a
|
|
48
|
+
* path flag then looked for on disk, `--target` recorded, and `--format` dropped on its way to a
|
|
49
|
+
* verdict `--exit-zero` turned green. Returns the refusal for the first such flag, else null.
|
|
50
|
+
*/
|
|
51
|
+
export declare function checkMissingValues(argv: readonly string[], registry: CliRegistry, command: string): string | null;
|
|
52
|
+
/** The refusal for a value flag given none: the flag, the value it takes, and where the flags are listed. */
|
|
53
|
+
export declare function missingValueRefusal(given: string, flag: FlagSpec, scope: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* The shape of a command's argv, read against its registry scope: every token is a flag,
|
|
56
|
+
* or the value of the flag before it, or a usage fault. Returns the refusal for the first token that
|
|
57
|
+
* is neither, else null.
|
|
58
|
+
*/
|
|
59
|
+
export declare function checkArgvShape(argv: readonly string[], registry: CliRegistry, command: string): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The positional arguments in a command's argv, in order: every word that is no flag and no flag's
|
|
62
|
+
* value. A flag the registry gives no value placeholder takes none, so `--new ZZ` reads ZZ as the
|
|
63
|
+
* positional, never as `--new`'s value — which `parseArgs` alone would make it.
|
|
64
|
+
*/
|
|
65
|
+
export declare function positionalArguments(argv: readonly string[], registry: CliRegistry, command: string): string[];
|
|
66
|
+
/** The refusal for a flag given more than once that is read once: the flag, and where. */
|
|
67
|
+
export declare function givenTwiceRefusal(given: string, scope: string): string;
|
|
68
|
+
/** A flag written with its value after an `=`, as in `--format=json`: a form this CLI does not read. */
|
|
69
|
+
export declare function isEqualsForm(token: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The refusal for a flag written `--flag=value`: the form as given, and the
|
|
72
|
+
* spelling that is read — the flag and its value as two arguments, or the flag alone when it takes
|
|
73
|
+
* none. Never the unknown-flag pin advice: no version reads the form, so no pin cures it. Refused
|
|
74
|
+
* rather than split, by ruling: one spelling means one reader of argv, where splitting would teach
|
|
75
|
+
* every reader of it the same answer.
|
|
76
|
+
*/
|
|
77
|
+
export declare function equalsFormRefusal(token: string, flags: ReadonlyMap<string, FlagSpec>, scope: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* A host modifier given after the command is out of place, not unknown: the
|
|
80
|
+
* flag exists, so the unknown-flag advice to bump a pin to a version that accepts it is false. Returns the
|
|
81
|
+
* refusal for the first such flag, else null.
|
|
82
|
+
*/
|
|
83
|
+
export declare function checkMisplacedHostModifiers(args: Record<string, string>, registry: CliRegistry, command: string): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* The registry-bounded flag check at a command's CLI edge. A command accepts ONLY
|
|
36
86
|
* the flags its per-command registry scope LISTS (by `name` or `alias`); an unregistered flag — a
|
|
37
|
-
* typo like `--strcit`, a stray `--bogus` — is a usage error,
|
|
38
|
-
*
|
|
39
|
-
*
|
|
87
|
+
* typo like `--strcit`, a stray `--bogus` — is a usage error, where the permissive parse above would
|
|
88
|
+
* have recorded it. It bounds flag NAMES and nothing else: a word that is no flag, a value given to a
|
|
89
|
+
* flag that takes none, a second copy, a `--flag=value` form, are `checkArgvShape`'s, which runs
|
|
90
|
+
* first. This is the structural teeth behind "accepted = registry
|
|
91
|
+
* = help": a flag cannot affect behaviour without a registry entry, and so (by the help-completeness
|
|
40
92
|
* guard) without appearing in that command's help.
|
|
41
93
|
*
|
|
42
94
|
* PURE and `@unit`-testable: the parsed args (keys already `--`-stripped) plus the registry and
|
|
43
95
|
* the command to bound against, returning the FIRST unregistered flag as a typed usage error
|
|
44
96
|
* naming it WITH its dashes — routed to stderr and the enumerated usage status 2 by the caller,
|
|
45
|
-
* never 1, never a silent run — else null. The global `--store`/`--run-id` modifiers
|
|
46
|
-
*
|
|
47
|
-
*
|
|
97
|
+
* never 1, never a silent run — else null. The global `--store`/`--run-id` modifiers are consumed
|
|
98
|
+
* by the top-level dispatcher when they come BEFORE the command; written after it they reach the
|
|
99
|
+
* command, and `checkMisplacedHostModifiers` refuses them as out of place before this runs.
|
|
48
100
|
*
|
|
49
101
|
* A COMMAND THE REGISTRY DOES NOT NAME ACCEPTS NOTHING, which is the honest reading rather than a
|
|
50
102
|
* degenerate one: an unregistered command has no scope, so every flag given to it is outside it.
|
|
51
103
|
* The dispatcher refuses such a command before this is ever reached, so the case is unreachable
|
|
52
104
|
* today and stated here so it cannot become a silent "accept everything" later.
|
|
53
105
|
*
|
|
54
|
-
* IT NAMES THE VERSION THAT REFUSED, AND THAT IS FOR THE PINNED READER
|
|
106
|
+
* IT NAMES THE VERSION THAT REFUSED, AND THAT IS FOR THE PINNED READER.
|
|
55
107
|
* A consumer pins spec-controller and then moves their own tree; the pinned reader is handed argv
|
|
56
108
|
* it was published too early — or too late — to understand, and an unadorned "unknown flag" is
|
|
57
109
|
* indistinguishable from a typo. Naming the running version makes version skew legible from the CI
|
|
@@ -65,6 +117,9 @@ export declare function parseArgs(argv: readonly string[]): Record<string, strin
|
|
|
65
117
|
* refusal is exactly that forbidden wrapper, and no other adopter could write one either. So the
|
|
66
118
|
* refusal is the tool's own, which makes it universal rather than local.
|
|
67
119
|
*
|
|
120
|
+
* EXCEPT FOR A FLAG THE COMMAND HAS RETIRED, where the bump is false advice: `retiredFlagRefusal`
|
|
121
|
+
* below names the retirement and its replacement instead.
|
|
122
|
+
*
|
|
68
123
|
* THE STATUS DOES NOT MOVE. The caller still routes this to stderr and exit 2. A mistyped `--strcit`
|
|
69
124
|
* is still a usage fault, and giving skew its own status would cost every adopter the ordinary
|
|
70
125
|
* reading to serve the rarer one.
|
package/dist/cli-args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../src/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAe,QAAQ,EAAkB,MAAM,mBAAmB,CAAC;AAE5F,4FAA4F;AAC5F,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBzE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAO9E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,IAAI,CAUf;AAED,6GAA6G;AAC7G,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAKxF;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC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