forked from bluesky-social/atproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbin.ts
32 lines (28 loc) · 743 Bytes
/
bin.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
#!/usr/bin/env node
import minimist from 'minimist'
import chalk from 'chalk'
import './commands/index.js'
import { matchCommand, runCommand } from './lib/command.js'
import { usage, commandUsage } from './lib/usage.js'
const VERSION = '0.0.1'
const args = minimist(process.argv.slice(2))
const cmd = matchCommand(args)
if (!cmd) {
if (args.version) {
console.log(VERSION)
process.exit(0)
}
usage(args._[0] ? `Invalid command: ${args._[0]}` : false)
} else {
if (args.h || args.help) {
commandUsage(cmd)
} else {
;(async () => {
try {
await runCommand(cmd, process.argv.slice(2 + cmd.nameParsed.length))
} catch (e: any) {
console.error(chalk.red(e.toString()))
}
})()
}
}