1 | #!/usr/bin/env node
|
2 |
|
3 | const fs = require('fs');
|
4 | const path = require('path');
|
5 | const blaze = require("./lib/blaze.js");
|
6 | const { spawn } = require('child_process');
|
7 | const program = require('commander');
|
8 | const package = require('./package.json');
|
9 |
|
10 | program
|
11 | .version(package.version, '-v, --version, version');
|
12 |
|
13 | program
|
14 | .command('start <dir>')
|
15 | .description('Start a Blaze Web Server instance')
|
16 | .action(
|
17 | async (dir, options) => {
|
18 | await blaze.start(dir);
|
19 | console.log('Starting Blaze');
|
20 | }
|
21 | );
|
22 |
|
23 | program
|
24 | .command('install <dir>')
|
25 | .alias('i')
|
26 | .description('Install the Blaze Web Server')
|
27 | .action(
|
28 | async (dir, options) => {
|
29 | await blaze.install(dir);
|
30 | }
|
31 | );
|
32 |
|
33 | program
|
34 | .command('uninstall <dir>')
|
35 | .alias('u')
|
36 | .description('Uninstall the Blaze Web Server')
|
37 | .action(
|
38 | async (dir, options) => {
|
39 | await blaze.uninstall(dir);
|
40 | }
|
41 | );
|
42 |
|
43 | program
|
44 | .command('parse <dir>')
|
45 | .alias('i')
|
46 | .option('-n, --name [name]', 'instance name')
|
47 | .description('Parse Blaze templates')
|
48 | .action(
|
49 | async (dir, options) => {
|
50 | let context = {}
|
51 | if (options.hasOwnProperty('context')) {
|
52 | try {
|
53 | context = JSON.parse(options.context);
|
54 | } catch { }
|
55 | }
|
56 | await blaze.parse(dir, options.hasOwnProperty('parser') ? options.parser : null, context);
|
57 | }
|
58 | );
|
59 |
|
60 | try {
|
61 | program.parse(process.argv);
|
62 | } catch (error) {
|
63 | console.error('ERROR: ' + error);
|
64 | } |
\ | No newline at end of file |