-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
39 lines (32 loc) · 890 Bytes
/
index.ts
File metadata and controls
39 lines (32 loc) · 890 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
39
import { config } from 'dotenv';
import chalkin from 'chalkin';
import { dayRunner } from './utils/dayRunner.ts';
config({ safe: true, export: true });
const year = Deno.env.get('CURRENT_YEAR');
const [mode, day, part, useFirstPartInput] = Deno.args;
if (!day) {
console.log(chalkin.red('Please specify a day'));
Deno.exit(1);
}
if (!year) {
console.log(chalkin.red('Please specify a year in .env file'));
Deno.exit(1);
}
if (!mode || !['data', 'sample'].includes(mode)) {
console.log(chalkin.red('Please specify a mode: data or sample'));
Deno.exit(1);
}
let parsedPart;
if (!part || !['1', '2'].includes(part)) {
console.log(chalkin.red('Please specify a part: 1 or 2'));
Deno.exit(1);
} else {
parsedPart = parseInt(part);
}
dayRunner({
year,
day,
mode: mode as 'data' | 'sample',
part: parsedPart,
useFirstPartInput: useFirstPartInput === 'true',
});