-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameMatcher.ts
More file actions
38 lines (36 loc) · 970 Bytes
/
GameMatcher.ts
File metadata and controls
38 lines (36 loc) · 970 Bytes
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 games from "./src/data/games";
import { statement } from "./src/statement";
import yargs from "yargs";
import fs from "fs/promises";
import path from "path";
import { hideBin } from "yargs/helpers";
import { Invoice } from "./src/types";
function printInvoiceStatementFor(invoicePath: string) {
fs.readFile(path.join(__dirname, invoicePath), {
encoding: "utf-8",
}).then((data) => {
const invoices: Invoice[] = JSON.parse(data) as Invoice[];
for (const invoice of invoices) {
console.info(statement(invoice, games));
}
});
}
yargs(hideBin(process.argv))
.usage("$0 <cmd> [args]")
.command(
"invoice [path]",
"Generate Invoice",
(yargs) => {
return yargs.positional("path", {
type: "string",
default: "invoices.json",
description: "Path to invoices json",
});
},
(args) => {
printInvoiceStatementFor(args.path);
}
)
.demandCommand(1)
.help()
.parseSync();