-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmod.ts
47 lines (36 loc) · 904 Bytes
/
mod.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
45
46
47
import { parse } from 'std/flags/mod.ts';
import { bold, green, red, yellow } from 'std/fmt/colors.ts';
import { AppName, Platform, Version } from './constants.ts';
import main from './app.ts';
const help = `${AppName} ${Version}-${Platform}
Usage:
${AppName} [arg1] [arg2]
${AppName} (-h | --help)
${AppName} (-v | --version)
Options:
-h, --help Print help
-v, --version Print version
[arg1]
[arg2]
`;
const args = parse(Deno.args);
if (args._.includes('help') || args?.h || args?.help) {
console.log(help);
Deno.exit(0);
}
if (args._.includes('version') || args?.v || args?.version) {
console.log(
green(bold(AppName)) +
' ' +
yellow(Version + '-' + Platform),
);
Deno.exit(0);
}
try {
await main(args);
} catch (error) {
console.log(red(bold('!')), 'An error occurred!');
if (args?.debug) {
console.log(error);
}
}