spliterator 3.2.0 → 5.0.0
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/out/lib/AsyncSpliterator.d.ts.map +1 -1
- package/out/lib/AsyncSpliterator.js +6 -4
- package/out/lib/AsyncSpliterator.js.map +1 -1
- package/out/lib/BufferController.d.ts.map +1 -1
- package/out/lib/BufferController.js.map +1 -1
- package/out/lib/CSVSpliterator.d.ts +8 -6
- package/out/lib/CSVSpliterator.d.ts.map +1 -1
- package/out/lib/CSVSpliterator.js +8 -1
- package/out/lib/CSVSpliterator.js.map +1 -1
- package/out/lib/CharacterSequence.d.ts +10 -1
- package/out/lib/CharacterSequence.d.ts.map +1 -1
- package/out/lib/CharacterSequence.js +76 -26
- package/out/lib/CharacterSequence.js.map +1 -1
- package/out/lib/CompositeDataView.d.ts.map +1 -1
- package/out/lib/CompositeDataView.js.map +1 -1
- package/out/lib/IndexQueue.d.ts.map +1 -1
- package/out/lib/IndexQueue.js +3 -1
- package/out/lib/IndexQueue.js.map +1 -1
- package/out/lib/JSONSpliterator.d.ts.map +1 -1
- package/out/lib/JSONSpliterator.js +2 -2
- package/out/lib/JSONSpliterator.js.map +1 -1
- package/out/lib/PSVSpliterator.js.map +1 -1
- package/out/lib/SlidingWindow.d.ts.map +1 -1
- package/out/lib/SlidingWindow.js.map +1 -1
- package/out/lib/Spliterator.d.ts.map +1 -1
- package/out/lib/Spliterator.js +6 -4
- package/out/lib/Spliterator.js.map +1 -1
- package/out/lib/TSVSpliterator.js.map +1 -1
- package/out/lib/TextSpliterator.d.ts +2 -2
- package/out/lib/TextSpliterator.d.ts.map +1 -1
- package/out/lib/TextSpliterator.js +2 -4
- package/out/lib/TextSpliterator.js.map +1 -1
- package/out/lib/casing.js +3 -3
- package/out/lib/casing.js.map +1 -1
- package/out/lib/merge-async-iterators.d.ts.map +1 -1
- package/out/lib/merge-async-iterators.js +3 -2
- package/out/lib/merge-async-iterators.js.map +1 -1
- package/out/lib/parallel-map-runtime.d.ts +3 -1
- package/out/lib/parallel-map-runtime.d.ts.map +1 -1
- package/out/lib/parallel-map-runtime.js +1 -1
- package/out/lib/parallel-map-runtime.js.map +1 -1
- package/out/lib/parallel-map-worker-entry.js +3 -2
- package/out/lib/parallel-map-worker-entry.js.map +1 -1
- package/out/lib/parallel-map.d.ts +12 -4
- package/out/lib/parallel-map.d.ts.map +1 -1
- package/out/lib/parallel-map.js +7 -3
- package/out/lib/parallel-map.js.map +1 -1
- package/out/lib/segment-runtime.d.ts.map +1 -1
- package/out/lib/segment-runtime.js +7 -4
- package/out/lib/segment-runtime.js.map +1 -1
- package/out/lib/segment-worker-entry.js +20 -17
- package/out/lib/segment-worker-entry.js.map +1 -1
- package/out/lib/segment-workers.d.ts +22 -9
- package/out/lib/segment-workers.d.ts.map +1 -1
- package/out/lib/segment-workers.js +8 -4
- package/out/lib/segment-workers.js.map +1 -1
- package/out/lib/segments.d.ts +9 -3
- package/out/lib/segments.d.ts.map +1 -1
- package/out/lib/segments.js +6 -4
- package/out/lib/segments.js.map +1 -1
- package/out/lib/shared.d.ts +3 -2
- package/out/lib/shared.d.ts.map +1 -1
- package/out/lib/shared.js +0 -2
- package/out/lib/shared.js.map +1 -1
- package/out/lib/take.d.ts.map +1 -1
- package/out/lib/take.js +3 -1
- package/out/lib/take.js.map +1 -1
- package/out/lib/wasm_module.d.ts +9 -3
- package/out/lib/wasm_module.d.ts.map +1 -1
- package/out/lib/wasm_module.js.map +1 -1
- package/out/lib/writer.d.ts +16 -5
- package/out/lib/writer.d.ts.map +1 -1
- package/out/lib/writer.js +20 -4
- package/out/lib/writer.js.map +1 -1
- package/out/node/cli/commands/csv.d.ts +3 -38
- package/out/node/cli/commands/csv.d.ts.map +1 -1
- package/out/node/cli/commands/csv.js +55 -47
- package/out/node/cli/commands/csv.js.map +1 -1
- package/out/node/cli/commands/iterate.d.ts +3 -31
- package/out/node/cli/commands/iterate.d.ts.map +1 -1
- package/out/node/cli/commands/iterate.js +45 -24
- package/out/node/cli/commands/iterate.js.map +1 -1
- package/out/node/cli/index.js +36 -22
- package/out/node/cli/index.js.map +1 -1
- package/out/node/cli/parse-args.d.ts +120 -0
- package/out/node/cli/parse-args.d.ts.map +1 -0
- package/out/node/cli/parse-args.js +118 -0
- package/out/node/cli/parse-args.js.map +1 -0
- package/out/node/cli/utils.d.ts +79 -28
- package/out/node/cli/utils.d.ts.map +1 -1
- package/out/node/cli/utils.js +63 -63
- package/out/node/cli/utils.js.map +1 -1
- package/out/node/fs/index.d.ts.map +1 -1
- package/out/node/fs/index.js +7 -3
- package/out/node/fs/index.js.map +1 -1
- package/package.json +13 -17
|
@@ -2,36 +2,8 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Default command — iterate over a file, line by line.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const command = "$0 [source] [destination]";
|
|
9
|
-
export declare const describe = false;
|
|
10
|
-
export declare const builder: (argv: Argv) => Argv<{
|
|
11
|
-
split: string;
|
|
12
|
-
} & {
|
|
13
|
-
join: string;
|
|
14
|
-
} & {
|
|
15
|
-
"skip-empty": boolean;
|
|
16
|
-
} & {
|
|
17
|
-
take: number | undefined;
|
|
18
|
-
} & {
|
|
19
|
-
drop: number;
|
|
20
|
-
} & {
|
|
21
|
-
debug: boolean;
|
|
22
|
-
} & {
|
|
23
|
-
"reader-high-water-mark": number;
|
|
24
|
-
} & {
|
|
25
|
-
"writer-high-water-mark": number;
|
|
26
|
-
} & {
|
|
27
|
-
filter: string | undefined;
|
|
28
|
-
} & {
|
|
29
|
-
source: unknown;
|
|
30
|
-
} & {
|
|
31
|
-
destination: unknown;
|
|
32
|
-
} & {
|
|
33
|
-
transformer: string | undefined;
|
|
34
|
-
}>;
|
|
35
|
-
export type IterateCommandArgs = PluckArgv<typeof builder>;
|
|
36
|
-
export declare const handler: (argv: ArgumentsCamelCase<IterateCommandArgs>) => Promise<void>;
|
|
7
|
+
export declare const help: string;
|
|
8
|
+
export declare function run(args: string[]): Promise<void>;
|
|
37
9
|
//# sourceMappingURL=iterate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate.d.ts","sourceRoot":"","sources":["../../../../node/cli/commands/iterate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"iterate.d.ts","sourceRoot":"","sources":["../../../../node/cli/commands/iterate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,eAAO,MAAM,IAAI,QAQL,CAAA;AAEZ,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAmEvD"}
|
|
@@ -2,45 +2,65 @@
|
|
|
2
2
|
* @copyright Sister Software
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file Default command — iterate over a file, line by line.
|
|
5
6
|
*/
|
|
6
7
|
import { resolve as resolvePath } from "node:path";
|
|
8
|
+
import { parseArgs } from "node:util";
|
|
7
9
|
import { CharacterSequence, Spliterator } from "spliterator";
|
|
8
10
|
import { createFileWritableStream, createReadStream } from "spliterator/node/fs";
|
|
9
|
-
import {
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
import { commonOptions, commonOptionsHelp, resolveIO, toNumber, } from "../utils.js";
|
|
12
|
+
export const help = [
|
|
13
|
+
"Iterate over a file, line by line, writing the transformed output to a new file.",
|
|
14
|
+
"",
|
|
15
|
+
"Usage: spliterator [source] [destination] [options]",
|
|
16
|
+
"",
|
|
17
|
+
"Options:",
|
|
18
|
+
commonOptionsHelp,
|
|
19
|
+
" -T, --transformer <path> Path to JS file exporting a default transformer function",
|
|
20
|
+
].join("\n");
|
|
21
|
+
export async function run(args) {
|
|
22
|
+
const { values, positionals } = parseArgs({
|
|
23
|
+
args,
|
|
24
|
+
allowPositionals: true,
|
|
25
|
+
allowNegative: true,
|
|
26
|
+
options: {
|
|
27
|
+
...commonOptions,
|
|
28
|
+
transformer: { type: "string", short: "T" },
|
|
29
|
+
},
|
|
17
30
|
});
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
if (values.help) {
|
|
32
|
+
console.log(help);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const [source, destination] = resolveIO(positionals, values);
|
|
36
|
+
const take = toNumber("take", values.take);
|
|
37
|
+
const drop = toNumber("drop", values.drop);
|
|
38
|
+
const readerHighWaterMark = toNumber("reader-high-water-mark", values["reader-high-water-mark"]);
|
|
39
|
+
const writerHighWaterMark = toNumber("writer-high-water-mark", values["writer-high-water-mark"]);
|
|
20
40
|
let transformer = (line) => line;
|
|
21
|
-
const joinDelimiter = new CharacterSequence(
|
|
22
|
-
if (
|
|
23
|
-
const module = await import(resolvePath(
|
|
41
|
+
const joinDelimiter = new CharacterSequence(values.join);
|
|
42
|
+
if (values.transformer) {
|
|
43
|
+
const module = await import(resolvePath(values.transformer));
|
|
24
44
|
transformer = module.default;
|
|
25
45
|
}
|
|
26
46
|
let filter = () => true;
|
|
27
|
-
if (
|
|
28
|
-
const module = await import(resolvePath(
|
|
47
|
+
if (values.filter) {
|
|
48
|
+
const module = await import(resolvePath(values.filter));
|
|
29
49
|
filter = module.default;
|
|
30
50
|
}
|
|
31
51
|
const [readStream, writeStream] = await Promise.all([
|
|
32
|
-
createReadStream(
|
|
33
|
-
createFileWritableStream(
|
|
34
|
-
highWaterMark:
|
|
52
|
+
createReadStream(source, readerHighWaterMark),
|
|
53
|
+
createFileWritableStream(destination, {
|
|
54
|
+
highWaterMark: writerHighWaterMark,
|
|
35
55
|
}),
|
|
36
56
|
]);
|
|
37
57
|
const writer = writeStream.getWriter();
|
|
38
58
|
const spliterator = Spliterator.from(readStream, {
|
|
39
|
-
delimiter:
|
|
40
|
-
skipEmpty:
|
|
41
|
-
take
|
|
42
|
-
drop
|
|
43
|
-
debug:
|
|
59
|
+
delimiter: values.split,
|
|
60
|
+
skipEmpty: values["skip-empty"],
|
|
61
|
+
take,
|
|
62
|
+
drop,
|
|
63
|
+
debug: values.debug,
|
|
44
64
|
});
|
|
45
65
|
for await (const line of spliterator) {
|
|
46
66
|
const transformed = await transformer(line);
|
|
@@ -50,5 +70,6 @@ export const handler = async (argv) => {
|
|
|
50
70
|
await writer.write(transformed);
|
|
51
71
|
await writer.write(joinDelimiter);
|
|
52
72
|
}
|
|
53
|
-
|
|
73
|
+
await writer.close();
|
|
74
|
+
}
|
|
54
75
|
//# sourceMappingURL=iterate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../../../node/cli/commands/iterate.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"iterate.js","sourceRoot":"","sources":["../../../../node/cli/commands/iterate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEhF,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,QAAQ,GAIR,MAAM,aAAa,CAAA;AAEpB,MAAM,CAAC,MAAM,IAAI,GAAG;IACnB,kFAAkF;IAClF,EAAE;IACF,qDAAqD;IACrD,EAAE;IACF,UAAU;IACV,iBAAiB;IACjB,0FAA0F;CAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc;IACvC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,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,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QACvD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAA;IACxB,CAAC;IAED,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACnD,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,CAAC;QAC7C,wBAAwB,CAAC,WAAW,EAAE;YACrC,aAAa,EAAE,mBAAmB;SAClC,CAAC;KACF,CAAC,CAAA;IAEF,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;IAEtC,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE;QAChD,SAAS,EAAE,MAAM,CAAC,KAAK;QACvB,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC;QAC/B,IAAI;QACJ,IAAI;QACJ,KAAK,EAAE,MAAM,CAAC,KAAK;KACnB,CAAC,CAAA;IAEF,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAA;QAE3C,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;QAE/B,IAAI,CAAC,IAAI;YAAE,SAAQ;QAEnB,MAAM,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;AACrB,CAAC"}
|
package/out/node/cli/index.js
CHANGED
|
@@ -5,30 +5,44 @@
|
|
|
5
5
|
* @author Teffen Ellis, et al.
|
|
6
6
|
* @file CLI entry point for the Spliterator library.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
// ---
|
|
15
|
-
"Iterate over a file, line by line, writing the transformed output to a new file.",
|
|
16
|
-
"$0 [source] [destination]",
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import * as csv from "./commands/csv.js";
|
|
10
|
+
import * as iterate from "./commands/iterate.js";
|
|
11
|
+
import { usageError } from "./utils.js";
|
|
12
|
+
const rootHelp = [
|
|
13
|
+
iterate.help,
|
|
17
14
|
"",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.usage([
|
|
21
|
-
// ---
|
|
22
|
-
"Split a CSV file into JSONL format.",
|
|
23
|
-
"$0 csv [source] [destination]",
|
|
15
|
+
"Commands:",
|
|
16
|
+
" csv Split a CSV file into JSONL format.",
|
|
24
17
|
"",
|
|
25
|
-
].join("\n"))
|
|
26
|
-
.epilogue([
|
|
27
|
-
// ---
|
|
28
18
|
"Sister Software, AGPL-3.0",
|
|
29
19
|
"https://sister.software",
|
|
30
|
-
].join("\n")
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
20
|
+
].join("\n");
|
|
21
|
+
const argv = process.argv.slice(2);
|
|
22
|
+
const [first, ...rest] = argv;
|
|
23
|
+
try {
|
|
24
|
+
switch (first) {
|
|
25
|
+
case "csv":
|
|
26
|
+
await csv.run(rest);
|
|
27
|
+
break;
|
|
28
|
+
case "--version":
|
|
29
|
+
console.log(createRequire(import.meta.url)("../../../package.json").version);
|
|
30
|
+
break;
|
|
31
|
+
case undefined:
|
|
32
|
+
case "help":
|
|
33
|
+
case "--help":
|
|
34
|
+
case "-h":
|
|
35
|
+
console.log(rootHelp);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
await iterate.run(argv);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
// `parseArgs` rejects unknown or malformed flags — report those as usage errors, not crashes.
|
|
43
|
+
if (error instanceof Error && String(error.code).startsWith("ERR_PARSE_ARGS")) {
|
|
44
|
+
usageError(error.message);
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
34
48
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../node/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../node/cli/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEvC,MAAM,QAAQ,GAAG;IAChB,OAAO,CAAC,IAAI;IACZ,EAAE;IACF,WAAW;IACX,qEAAqE;IACrE,EAAE;IACF,2BAA2B;IAC3B,yBAAyB;CACzB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClC,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;AAE7B,IAAI,CAAC;IACJ,QAAQ,KAAK,EAAE,CAAC;QACf,KAAK,KAAK;YACT,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACnB,MAAK;QAEN,KAAK,WAAW;YACf,OAAO,CAAC,GAAG,CAAE,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,uBAAuB,CAAyB,CAAC,OAAO,CAAC,CAAA;YACrG,MAAK;QAEN,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI;YACR,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YACrB,MAAK;QAEN;YACC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;AACF,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IAChB,8FAA8F;IAC9F,IAAI,KAAK,YAAY,KAAK,IAAI,MAAM,CAAE,KAA+B,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1G,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,KAAK,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file A minimal command/option layer over Node's built-in `util.parseArgs`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Declarative description of a single command line option.
|
|
9
|
+
*/
|
|
10
|
+
export interface OptionSpec {
|
|
11
|
+
/**
|
|
12
|
+
* The value type. `number` options are parsed as strings and coerced.
|
|
13
|
+
*/
|
|
14
|
+
type: "string" | "boolean" | "number";
|
|
15
|
+
/**
|
|
16
|
+
* Single-character alias, e.g. `s` for `-s`.
|
|
17
|
+
*/
|
|
18
|
+
short?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Help text shown alongside the option.
|
|
21
|
+
*/
|
|
22
|
+
description: string;
|
|
23
|
+
/**
|
|
24
|
+
* Value used when the option is omitted.
|
|
25
|
+
*/
|
|
26
|
+
default?: string | number | boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Human-readable stand-in for `default` in help output, e.g. `<newline>`.
|
|
29
|
+
*/
|
|
30
|
+
defaultDescription?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Permitted values for string options. Anything else is rejected.
|
|
33
|
+
*/
|
|
34
|
+
choices?: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
export type OptionRecord = Record<string, OptionSpec>;
|
|
37
|
+
/**
|
|
38
|
+
* Declarative description of a positional argument.
|
|
39
|
+
*/
|
|
40
|
+
export interface PositionalSpec {
|
|
41
|
+
/**
|
|
42
|
+
* Help text shown alongside the positional.
|
|
43
|
+
*/
|
|
44
|
+
description: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the positional must be present.
|
|
47
|
+
*/
|
|
48
|
+
required?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export type PositionalRecord = Record<string, PositionalSpec>;
|
|
51
|
+
type KebabToCamel<T extends string> = T extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<KebabToCamel<Tail>>}` : T;
|
|
52
|
+
type OptionValue<S extends OptionSpec> = S extends {
|
|
53
|
+
choices: readonly (infer Choice)[];
|
|
54
|
+
} ? Choice : S["type"] extends "boolean" ? boolean : S["type"] extends "number" ? number : string;
|
|
55
|
+
type OptionalKeys<O extends OptionRecord> = {
|
|
56
|
+
[K in keyof O]: O[K] extends {
|
|
57
|
+
default: unknown;
|
|
58
|
+
} ? never : K;
|
|
59
|
+
}[keyof O];
|
|
60
|
+
/**
|
|
61
|
+
* The parsed shape of an option record, with kebab-case keys camel-cased.
|
|
62
|
+
*/
|
|
63
|
+
export type InferOptions<O extends OptionRecord> = {
|
|
64
|
+
[K in Exclude<keyof O, OptionalKeys<O>> & string as KebabToCamel<K>]: OptionValue<O[K]>;
|
|
65
|
+
} & {
|
|
66
|
+
[K in OptionalKeys<O> & string as KebabToCamel<K>]?: OptionValue<O[K]>;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* The parsed shape of a positional record.
|
|
70
|
+
*/
|
|
71
|
+
export type InferPositionals<P extends PositionalRecord> = {
|
|
72
|
+
[K in keyof P & string as KebabToCamel<K>]: P[K] extends {
|
|
73
|
+
required: true;
|
|
74
|
+
} ? string : string | undefined;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* A CLI command — a name, its options, and the handler invoked with parsed arguments.
|
|
78
|
+
*/
|
|
79
|
+
export interface Command<O extends OptionRecord = OptionRecord, P extends PositionalRecord = PositionalRecord> {
|
|
80
|
+
/**
|
|
81
|
+
* The subcommand name, or `null` for the default command.
|
|
82
|
+
*/
|
|
83
|
+
name: string | null;
|
|
84
|
+
/**
|
|
85
|
+
* One-line summary shown in the top-level help.
|
|
86
|
+
*/
|
|
87
|
+
description: string;
|
|
88
|
+
/**
|
|
89
|
+
* Usage line shown in the command's help, sans script name.
|
|
90
|
+
*/
|
|
91
|
+
usage: string;
|
|
92
|
+
options: O;
|
|
93
|
+
positionals: P;
|
|
94
|
+
handler: (args: InferOptions<O> & InferPositionals<P>) => Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Identity helper preserving the literal types of a command's option and positional records.
|
|
98
|
+
*/
|
|
99
|
+
export declare function defineCommand<O extends OptionRecord, P extends PositionalRecord>(command: Command<O, P>): Command<O, P>;
|
|
100
|
+
/**
|
|
101
|
+
* Thrown when the user supplies arguments the command cannot accept.
|
|
102
|
+
*
|
|
103
|
+
* The CLI entry point prints the message and exits without a stack trace.
|
|
104
|
+
*/
|
|
105
|
+
export declare class UsageError extends Error {
|
|
106
|
+
name: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse `argv` against a command, applying defaults, coercion, and validation.
|
|
110
|
+
*
|
|
111
|
+
* @param command - The command to parse against.
|
|
112
|
+
* @param argv - Arguments following the command name.
|
|
113
|
+
*/
|
|
114
|
+
export declare function parseCommand<O extends OptionRecord, P extends PositionalRecord>(command: Command<O, P>, argv: string[]): InferOptions<O> & InferPositionals<P>;
|
|
115
|
+
/**
|
|
116
|
+
* Render the help text for a single command.
|
|
117
|
+
*/
|
|
118
|
+
export declare function formatCommandHelp(scriptName: string, command: Command): string;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=parse-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.d.ts","sourceRoot":"","sources":["../../../node/cli/parse-args.ts"],"names":[],"mappings":"AAAA;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vE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,gBAAgB,EAC/E,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAEf;AAMD;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IAC3B,IAAI,SAAe;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,gBAAgB,EAC9E,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,EAAE,GACZ,YAAY,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAwEvC;AASD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CA0B9E"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* @file A minimal command/option layer over Node's built-in `util.parseArgs`.
|
|
6
|
+
*/
|
|
7
|
+
import { parseArgs } from "node:util";
|
|
8
|
+
/**
|
|
9
|
+
* Identity helper preserving the literal types of a command's option and positional records.
|
|
10
|
+
*/
|
|
11
|
+
export function defineCommand(command) {
|
|
12
|
+
return command;
|
|
13
|
+
}
|
|
14
|
+
function camelCase(input) {
|
|
15
|
+
return input.replace(/-([a-z])/g, (_, character) => character.toUpperCase());
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thrown when the user supplies arguments the command cannot accept.
|
|
19
|
+
*
|
|
20
|
+
* The CLI entry point prints the message and exits without a stack trace.
|
|
21
|
+
*/
|
|
22
|
+
export class UsageError extends Error {
|
|
23
|
+
name = "UsageError";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse `argv` against a command, applying defaults, coercion, and validation.
|
|
27
|
+
*
|
|
28
|
+
* @param command - The command to parse against.
|
|
29
|
+
* @param argv - Arguments following the command name.
|
|
30
|
+
*/
|
|
31
|
+
export function parseCommand(command, argv) {
|
|
32
|
+
const config = {};
|
|
33
|
+
for (const [name, spec] of Object.entries(command.options)) {
|
|
34
|
+
config[name] = {
|
|
35
|
+
type: spec.type === "number" ? "string" : spec.type,
|
|
36
|
+
...(spec.short ? { short: spec.short } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = parseArgs({
|
|
42
|
+
args: argv,
|
|
43
|
+
options: config,
|
|
44
|
+
allowPositionals: true,
|
|
45
|
+
allowNegative: true,
|
|
46
|
+
strict: true,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new UsageError(error instanceof Error ? error.message : String(error));
|
|
51
|
+
}
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const [name, spec] of Object.entries(command.options)) {
|
|
54
|
+
const key = camelCase(name);
|
|
55
|
+
const raw = parsed.values[name];
|
|
56
|
+
if (raw === undefined) {
|
|
57
|
+
if (spec.default !== undefined)
|
|
58
|
+
result[key] = spec.default;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (spec.type === "number") {
|
|
62
|
+
const value = Number(raw);
|
|
63
|
+
if (!Number.isFinite(value)) {
|
|
64
|
+
throw new UsageError(`Option --${name} expects a number, received "${String(raw)}".`);
|
|
65
|
+
}
|
|
66
|
+
result[key] = value;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (spec.choices && !spec.choices.includes(raw)) {
|
|
70
|
+
throw new UsageError(`Option --${name} expects one of: ${spec.choices.join(", ")}.`);
|
|
71
|
+
}
|
|
72
|
+
result[key] = raw;
|
|
73
|
+
}
|
|
74
|
+
const positionalNames = Object.keys(command.positionals);
|
|
75
|
+
if (parsed.positionals.length > positionalNames.length) {
|
|
76
|
+
throw new UsageError(`Unexpected argument "${parsed.positionals[positionalNames.length]}".`);
|
|
77
|
+
}
|
|
78
|
+
for (const [index, name] of positionalNames.entries()) {
|
|
79
|
+
const key = camelCase(name);
|
|
80
|
+
// An explicit `--source`/`--destination` option wins over the positional slot.
|
|
81
|
+
const value = result[key] ?? parsed.positionals[index];
|
|
82
|
+
if (value === undefined && command.positionals[name].required) {
|
|
83
|
+
throw new UsageError(`Missing required argument "${name}".`);
|
|
84
|
+
}
|
|
85
|
+
result[key] = value;
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
function formatDefault(spec) {
|
|
90
|
+
if (spec.defaultDescription)
|
|
91
|
+
return spec.defaultDescription;
|
|
92
|
+
if (spec.default === undefined)
|
|
93
|
+
return "";
|
|
94
|
+
return JSON.stringify(spec.default);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Render the help text for a single command.
|
|
98
|
+
*/
|
|
99
|
+
export function formatCommandHelp(scriptName, command) {
|
|
100
|
+
const lines = [command.description, "", `Usage: ${scriptName} ${command.usage}`, ""];
|
|
101
|
+
const positionalEntries = Object.entries(command.positionals);
|
|
102
|
+
if (positionalEntries.length) {
|
|
103
|
+
lines.push("Positionals:");
|
|
104
|
+
for (const [name, spec] of positionalEntries) {
|
|
105
|
+
lines.push(` ${name.padEnd(28)}${spec.description}${spec.required ? "" : " (optional)"}`);
|
|
106
|
+
}
|
|
107
|
+
lines.push("");
|
|
108
|
+
}
|
|
109
|
+
lines.push("Options:");
|
|
110
|
+
for (const [name, spec] of Object.entries(command.options)) {
|
|
111
|
+
const flag = [spec.short ? `-${spec.short},` : " ", `--${name}`].join(" ");
|
|
112
|
+
const fallback = formatDefault(spec);
|
|
113
|
+
const choices = spec.choices ? ` [${spec.choices.join("|")}]` : "";
|
|
114
|
+
lines.push(` ${flag.padEnd(32)}${spec.description}${choices}${fallback ? ` (default: ${fallback})` : ""}`);
|
|
115
|
+
}
|
|
116
|
+
return lines.join("\n");
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=parse-args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-args.js","sourceRoot":"","sources":["../../../node/cli/parse-args.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAA;AAiH3D;;GAEG;AACH,MAAM,UAAU,aAAa,CAC5B,OAAsB;IAEtB,OAAO,OAAO,CAAA;AACf,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,SAAiB,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAA;AACrF,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC3B,IAAI,GAAG,YAAY,CAAA;CAC5B;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAC3B,OAAsB,EACtB,IAAc;IAEd,MAAM,MAAM,GAA+B,EAAE,CAAA;IAE7C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5D,MAAM,CAAC,IAAI,CAAC,GAAG;YACd,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;YACnD,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5C,CAAA;IACF,CAAC;IAED,IAAI,MAAwF,CAAA;IAE5F,IAAI,CAAC;QACJ,MAAM,GAAG,SAAS,CAAC;YAClB,IAA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G,CAAC,CAAC,CAAC,EAAE,CAAA;QAElE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,WAAW,GAAG,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5G,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC"}
|
package/out/node/cli/utils.d.ts
CHANGED
|
@@ -3,32 +3,83 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
* @author Teffen Ellis, et al.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Options accepted by every Spliterator command.
|
|
8
|
+
*/
|
|
9
|
+
export declare const commonOptions: {
|
|
10
|
+
readonly split: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly short: "s";
|
|
13
|
+
readonly default: "\n";
|
|
14
|
+
};
|
|
15
|
+
readonly join: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly short: "j";
|
|
18
|
+
readonly default: "\n";
|
|
19
|
+
};
|
|
20
|
+
readonly "skip-empty": {
|
|
21
|
+
readonly type: "boolean";
|
|
22
|
+
readonly short: "e";
|
|
23
|
+
readonly default: true;
|
|
24
|
+
};
|
|
25
|
+
readonly take: {
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly short: "t";
|
|
28
|
+
};
|
|
29
|
+
readonly drop: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly short: "p";
|
|
32
|
+
readonly default: "0";
|
|
33
|
+
};
|
|
34
|
+
readonly debug: {
|
|
35
|
+
readonly type: "boolean";
|
|
36
|
+
readonly short: "v";
|
|
37
|
+
readonly default: false;
|
|
38
|
+
};
|
|
39
|
+
readonly "reader-high-water-mark": {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
readonly short: "w";
|
|
42
|
+
readonly default: string;
|
|
43
|
+
};
|
|
44
|
+
readonly "writer-high-water-mark": {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
readonly short: "W";
|
|
47
|
+
readonly default: string;
|
|
48
|
+
};
|
|
49
|
+
readonly filter: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly short: "f";
|
|
52
|
+
};
|
|
53
|
+
readonly source: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly short: "i";
|
|
56
|
+
};
|
|
57
|
+
readonly destination: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly short: "o";
|
|
60
|
+
};
|
|
61
|
+
readonly help: {
|
|
62
|
+
readonly type: "boolean";
|
|
63
|
+
readonly short: "h";
|
|
64
|
+
readonly default: false;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export declare const commonOptionsHelp: string;
|
|
68
|
+
/**
|
|
69
|
+
* Coerce a numeric option, exiting with a usage error if it isn't a number.
|
|
70
|
+
*/
|
|
71
|
+
export declare function toNumber(name: string, input: string | undefined): number | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Resolve the source and destination paths from positionals, falling back to their flag forms.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveIO(positionals: string[], values: {
|
|
76
|
+
source?: string;
|
|
77
|
+
destination?: string;
|
|
78
|
+
}): [source: string, destination: string];
|
|
79
|
+
/**
|
|
80
|
+
* Print a usage error and exit.
|
|
81
|
+
*/
|
|
82
|
+
export declare function usageError(message: string): never;
|
|
32
83
|
/**
|
|
33
84
|
* A function that filters lines from a spliterator's output.
|
|
34
85
|
*
|
|
@@ -46,7 +97,7 @@ export type LineTransformer<T = unknown> = (line: Uint8Array) => T | PromiseLike
|
|
|
46
97
|
/**
|
|
47
98
|
* The default export from a module that exports a `LineTransformer`.
|
|
48
99
|
*/
|
|
49
|
-
export
|
|
100
|
+
export interface LineTransformerModuleExports {
|
|
50
101
|
default: LineTransformer;
|
|
51
|
-
}
|
|
102
|
+
}
|
|
52
103
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../node/cli/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../node/cli/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,eAAO,MAAM,aAAa;;iBAChB,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO,EAAE,IAAI;;;iBAC1C,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO,EAAE,IAAI;;;iBACjC,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO;;;iBAC5C,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;;;iBAC1B,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO,EAAE,GAAG;;;iBACvC,IAAI,EAAE,SAAS;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO;;;iBACjB,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO;;;iBACnC,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;iBAAE,OAAO;;;iBACrD,IAAI,EAAE,QAAQ;iBAAE,KAAK,EAAE,GAAG;;;iBAC1B,IAAI,EAA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