UNPKG

643 BPlain TextView Raw
1#!/usr/bin/env node
2
3import program from 'commander'
4import { generateDefinition } from '.'
5
6export async function exec(argv: string[]) {
7 program
8 .name('fts')
9 .usage('[options] <file.ts>')
10 .option('-p, --project <project>', "Path to 'tsconfig.json'.")
11 .parse(argv)
12
13 let file: string
14 if (program.args.length === 1) {
15 file = program.args[0]
16 } else {
17 console.error('invalid arguments')
18 program.help()
19 process.exit(1)
20 }
21
22 const definition = await generateDefinition(file)
23 console.log(JSON.stringify(definition, null, 2))
24}
25
26exec(process.argv).catch((err) => {
27 console.error(err)
28 process.exit(1)
29})