-
Notifications
You must be signed in to change notification settings - Fork 0
/
rio.js
executable file
·52 lines (43 loc) · 1.15 KB
/
rio.js
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
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env node
const childProcess = require('child_process');
const { Command } = require('commander');
const rio = require('./src/index');
const program = new Command();
program
.version('0.0.1');
function callCommand(path, options, callback) {
rio.cli = true;
let isPrivate = options.private;
if (isPrivate == null) {
isPrivate = false;
}
// eslint-disable-next-line
const { server } = require(path);
const isPublic = !isPrivate;
callback(isPublic);
if (server) {
server.close();
}
}
program
.command('init')
.argument('[path]', 'path to api', './api.js')
.option('--private', 'Whether to make it public or not')
.description('Initialize')
.action((path, options) => {
callCommand(path, options, (isPublic) => {
rio.writeREADME(process.cwd(), isPublic);
});
});
program
.command('oas')
.argument('[path]', 'path to api', './api.js')
.option('--private', 'Whether to make it public or not')
.description('Create OAS')
.action((path, options) => {
callCommand(path, options, (isPublic) => {
rio.oasGenerate(process.cwd(), isPublic);
});
});
program
.parse(childProcess.argv);