-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
28 lines (22 loc) · 671 Bytes
/
Copy pathmain.ts
File metadata and controls
28 lines (22 loc) · 671 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
import docopt from "https://deno.land/x/docopt@v1.0.6/mod.ts";
import { generateNIN } from "./mod.ts";
const doc = `
National Identification Number Generator
Usage:
nin [-v] [--year=<yyyy>]
Options:
-h --help Show this screen
-v --verbose Print more info about the NIN
-y --year=<yyyy> Birth year (default: random)
`;
type Year = number | null;
try {
const args = docopt(doc);
const year: Year = typeof args["--year"] === "string"
? parseInt(args["--year"]) || null
: null;
const verbose = args["--verbose"] == true; // convert Value to boolean
console.log(generateNIN(year, verbose));
} catch (e) {
console.error(e.message);
}