-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcli.ts
executable file
·64 lines (59 loc) · 1.19 KB
/
cli.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
import meow from 'meow';
import main from './index';
import Text from './lib/text';
import { FlagTypes } from './types';
import { InvalidInputError } from './lib/error';
import { sanitizeInput } from './lib/utils/sanitize';
async function cli(argv: string[]) {
const cli = meow({
argv,
help: Text.mainText.help,
flags: {
auth: {
type: 'string',
},
branch: {
type: 'string',
},
concurrency: {
type: 'number',
default: 10,
},
json: {
type: 'boolean',
},
last: {
type: 'number',
},
period: {
type: 'number',
},
since: {
type: 'number',
},
},
});
try {
if (cli.input.length < 1) {
cli.showHelp();
}
const [repoSlug, command] = await sanitizeInput(cli.input);
await main({
cwd: __dirname,
repoSlug,
command,
flags: cli.flags as FlagTypes,
});
} catch (err) {
if (err instanceof InvalidInputError) {
console.error(err.getMessage());
} else {
throw err;
}
}
}
cli(process.argv.slice(2)).catch((err) => {
console.error(err);
process.exit(1);
});