-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
38 lines (31 loc) · 965 Bytes
/
main.ts
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
import { parseArgs } from "https://deno.land/[email protected]/cli/parse_args.ts";
import { flatten } from "./lib/resolver.ts"
import { formatAsSet } from "./lib/formatter.ts";
import { asnSorter } from "./lib/helpers.ts";
import { config } from "./flattener.config.ts";
export interface GlobalInterface {
verboseMode?: boolean
}
export const global: GlobalInterface = {};
const flags = parseArgs(Deno.args, {
boolean: ["help", "verbose"]
});
if (flags.help) {
console.log(`Usage: ${import.meta.filename} [OPTIONS]
Options:
--help Show this menu.
--verbose Log what the flattener is doing to stdout.`);
Deno.exit(0);
}
const flattened = await flatten(
config.flattenerOptions.asSet,
config.flattenerOptions.whoisServer,
flags.verbose || false
);
console.log(formatAsSet({
members: [
"AS51019",
...flattened.sort(asnSorter).map(asn => asn.toUpperCase())
],
...config.resultOptions,
}))