forked from grahamjenson/hapiger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.coffee
50 lines (36 loc) · 1.47 KB
/
cli.coffee
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
bb = require 'bluebird'
_ = require "underscore"
program = require('commander');
chalk = require 'chalk'
HapiGER = require('./lib/hapi_server')
cli = ->
environment = _.defaults( process.env, {
PORT: 4567
})
program
.version('0.0.2')
.usage('[options]')
.description('start a hapiger server')
.option('-p, --port <port>', 'the port to start the server on', 3456)
.option('-e, --es <esm>', 'select Event Store [memory, pg, rethinkdb, mysql]', 'memory')
.option('-E, --esoptions <options>', 'JSON representation of Options for Event Store e.g. "{"url": "postgres://localhost/hapiger"}"
\n\t memory -- {}
\n\t pg -- {"url" : "postgres url"}
\n\t rethinkdb -- {"host": "rethinkdb host", "port": "rethink port", "db": "rethink database"}
\n\t mysql -- {"connection": {"host": "mysql host", "port": "mysql port", "user": "mysql user", "password": "mysql password"}}
', ((input) -> JSON.parse(input)), {})
.option('-v, --verbose', "More Output", false)
.option('-D --default_configuration', "Default Configuration to generate recommendations", {})
.parse(process.argv);
verbose = program.verbose
bb.Promise.longStackTraces() if verbose
hapiger = new HapiGER({
esm: program.es
esmoptions: program.esoptions
port: program.port
configuration: program.default_configuration
})
hapiger.initialize()
.then( -> hapiger.start())
.catch((e) -> console.log "ERROR"; console.log e.stack)
module.exports = cli