-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
41 lines (35 loc) · 973 Bytes
/
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
39
40
41
#!/usr/bin/env node
import arg from 'arg';
import colors from 'colors';
import pkg = require('./package.json');
import { createBoilerplate } from './lib/create';
// Flag Creation
const args:any = arg({
// Types
'--help': Boolean,
'--version': Boolean,
'--name': String,
// Aliases
'-h': '--help',
'-v': '--version',
'-n': '--name'
});
// Handle version request
if (args['--version']) {
console.log(colors.white(`${pkg.name} v${pkg.version}`));
process.exit(0);
}
// Handle help or empty request
if (args['--help'] || (!args._[0])) {
console.log(`
${pkg.name} - ${pkg.description}
${colors.cyan("USAGE:")}
${pkg.name} myapp
${colors.cyan("OPTIONS:")}
--help, -h Displays this help message.
--version, -v Outputs the current ${pkg.name} version.
--name, -n Your project name
`)
process.exit(0);
}
createBoilerplate(args);