1 | dashdash = require 'dashdash'
|
2 | ReporterRunner = require './src/reporter-runner'
|
3 |
|
4 | options = [
|
5 | {
|
6 | name: 'version'
|
7 | type: 'bool'
|
8 | help: 'Print tool version and exit.'
|
9 | }
|
10 | {
|
11 | names: ['help', 'h']
|
12 | type: 'bool'
|
13 | help: 'Print this help and exit.'
|
14 | }
|
15 | {
|
16 | name: 'dry-run'
|
17 | type: 'bool'
|
18 | help: 'Print results, do not post to statuspage.io'
|
19 | }
|
20 | {
|
21 | names: ['elasticsearch-uri', 'e']
|
22 | type: 'string'
|
23 | env: 'ELASTICSEARCH_URI'
|
24 | help: 'ElasticSearch URI'
|
25 | helpArg: 'URI'
|
26 | }
|
27 | {
|
28 | names: ['statuspage-api-key', 'k']
|
29 | type: 'string'
|
30 | env: 'STATUSPAGE_API_KEY'
|
31 | help: 'StatusPage.io API key'
|
32 | helpArg: 'KEY'
|
33 | }
|
34 | ]
|
35 |
|
36 | parser = dashdash.createParser(options: options)
|
37 | try
|
38 | opts = parser.parse(process.argv)
|
39 | catch e
|
40 | console.error 'elastic-search-to-statuspage: error: %s', e.message
|
41 | process.exit 1
|
42 |
|
43 | if opts.help
|
44 | help = parser.help(includeEnv: true).trimRight()
|
45 | console.log 'usage: node command.js [OPTIONS]\n' + 'options:\n' + help
|
46 | process.exit 0
|
47 |
|
48 | reporterRunner = new ReporterRunner opts
|
49 | reporterRunner.run (error) =>
|
50 | if error
|
51 | console.error error.stack
|
52 | process.exit 1
|
53 | process.exit 0
|