-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
30 lines (24 loc) · 1.47 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
#! /usr/bin/env node
import { program } from 'commander'
import { version } from './package.json'
import { Yor, YorAlias } from './src/enums'
import { templates } from './src/utils'
program.command('create')
.version(version)
.description('Quick create yor module.')
.argument('<string>', 'Yor target module name.')
.option(`-${YorAlias.MODULE}, --${Yor.MODULE}`, 'Generate yor module dir, includes interface / controller / service / repo file, this command will create such files and export named vars from input argument.')
.option(`-${YorAlias.INTERFACE}, --${Yor.INTERFACE}`, 'Generate a yor interface, if there exist a named file this command will add interface at the end of file, or will create a new file.')
.option(`-${YorAlias.PROVIDER}, --${Yor.PROVIDER}`, 'Generate yor provider, and define current provider interface in same file.')
.option(`-${YorAlias.CONTROLLER}, --${Yor.CONTROLLER}`, 'Generate yor controller, and define current controller interface in same file.')
.option('--path <char>', 'Declare the target files / dir generation path.')
.action((str, options) => {
if (options[Yor.MODULE]) {
templates[Yor.MODULE](str, options.path)
return
}
if (options[Yor.INTERFACE]) { templates[Yor.INTERFACE](str, options.path) }
if (options[Yor.PROVIDER]) { templates[Yor.PROVIDER](str, options.path) }
if (options[Yor.INTERFACE]) { templates[Yor.INTERFACE](str, options.path) }
})
program.parse(process.argv)