-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.ts
29 lines (21 loc) · 857 Bytes
/
cli.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
#!/usr/bin/env node
import { Command } from "commander";
import fs from "fs";
import { Schema, Validator } from "jsonschema";
import path from "path";
import { generateHtml } from ".";
import { ManfredAwesomicCV } from "./lib/mac";
const program = new Command();
program
.name("mac-renderer")
.description("Convert a MAC JSON to HTML (stdout)")
.argument("<mac-file>", "MAC JSON file")
.action(async (macFile: string) => {
const schema: unknown = JSON.parse(fs.readFileSync(path.resolve(__dirname, "mac-schema.json"), "utf8"));
const input = fs.readFileSync(path.resolve(process.cwd(), macFile), "utf8");
const mac: unknown = JSON.parse(input);
new Validator().validate(mac, schema as Schema, { throwError: true });
const html = await generateHtml(mac as ManfredAwesomicCV);
console.log(html);
});
program.parse();