-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnd-sort.js
41 lines (34 loc) · 1.04 KB
/
nd-sort.js
1
2
3
4
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
32
33
34
35
36
37
38
39
40
41
import { ndsortcommand } from "./nd-sort/command.js";
import { createSortFunction, /*sortjson,*/ sorton } from "./nd-sort/sort.js";
import { helptext } from "./nd-sort/helptext.js";
import { generatorFactory } from "./generator/factory.js";
import { commonOptions, getArgs } from "./args.js";
if (import.meta.main) {
const options = { ...commonOptions };
options.alias = { ...options.alias, lang: "locales", locale: "locales" };
options.boolean = [...options.boolean, "reverse"];
options.default = { ...options.default, reverse: false };
const args = getArgs(Deno.args, options);
const {
on,
help,
numeric,
reverse,
locales,
_: [sortfxbody],
} = args;
const { stdin, exit } = Deno;
if (help) {
console.log(helptext);
exit(0);
}
const sortfx = on && on.length > 0
? sorton({ on, reverse, numeric, locales })
: createSortFunction({ sortfxbody, locales, reverse });
const generator = generatorFactory({ args, reader: stdin });
await ndsortcommand({
generator,
sortfx,
args,
});
}