-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
38 lines (31 loc) · 1.01 KB
/
index.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
#!/usr/bin/env node
import { Command } from 'commander'
import { listAction, listDesc, createAction, createDesc } from './commands'
void (async () => {
const program = new Command()
program
.name('apext')
.description('A simple CLI tool to manage and organize Next.js API routes.')
.version('0.2.0')
// COMMANDS
// LIST COMMAND - OPTIONS: --path
const list = program
.command('list')
.aliases(['ls, lst'])
.description(listDesc)
list.option('--path <path>', 'Path to look routes in. eg: --path=auth')
list.action(listAction)
// CREATE COMMAND - OPTIONS: --name --path
const create = program.command('create').description(createDesc)
create.argument('<name>', 'Name of the route to create.')
create.option('--path <path>', 'Path to create route in. eg: --path=auth')
create.option('--ts', 'If you want a Typescript file.')
create.action(createAction)
try {
await program.parseAsync()
process.exit()
} catch (err) {
console.error(err)
process.exit(1)
}
})()