-
Notifications
You must be signed in to change notification settings - Fork 120
/
lv-svr.js
60 lines (55 loc) · 1.28 KB
/
lv-svr.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
53
54
55
56
57
58
59
60
#!/usr/bin/env node
var program = require('commander')
program
.version(require('./package.json').version)
program
.command('start')
.description('start lambda-view web server')
.option('-b, --background', 'run in background')
.option('-p, --public', 'enable public access')
.action(function() {
console.log('starting lambda-view web server...')
var opt = {
background: this.background,
public: this.public
}
require('./fmtjs-web').start(opt, function(err, status) {
if (err) {
console.error(err.message)
return
}
console.log(status.url)
})
})
program
.command('stop')
.description('stop lambda-view web server')
.action(function() {
console.log('stopping lambda-view web server...')
require('./fmtjs-web').stop(function(err) {
if (err) {
console.error(err.message)
return
}
console.log('done.')
})
})
program
.command('status')
.description('retrieve lambda-view web server status')
.action(function() {
console.log('retrieving lambda-view web server status...')
require('./fmtjs-web').status(function(err, status) {
if (err) {
console.error(err.message)
return
}
console.log(status)
})
})
if (process.argv.length <= 2) {
program.parse(process.argv.concat(['--help']))
}
else {
program.parse(process.argv)
}