-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.ts
executable file
·44 lines (39 loc) · 1.06 KB
/
run.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
39
40
41
42
43
44
import { red } from './deps/std.ts';
import { generateErrorMessage, ZodError } from './deps/zod.ts';
import cli from './src/cli/mod.ts';
try {
const code = await cli.parse(Deno.args);
if (typeof code === 'number' && code !== 0) {
Deno.exit(code);
}
} catch (error) {
if (error instanceof ZodError) {
const message = generateErrorMessage(error.issues, {
delimiter: {
error: '\n',
component: ' ',
},
code: {
enabled: true,
transform: ({ value }) => `${value}:`,
},
path: {
enabled: true,
type: 'objectNotation',
transform: ({ value }) => `Attribute ${value}`,
},
message: {
enabled: true,
transform: ({ value }) => value,
},
});
console.error(red(message));
} else if (error instanceof Deno.errors.InvalidData) {
console.error(red(error.message));
} else if (error instanceof Deno.errors.NotFound) {
console.error(red(error.message));
} else {
console.error(red(error.stack || error.message));
}
Deno.exit(1);
}