-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathloghose.js
executable file
·53 lines (47 loc) · 1.37 KB
/
loghose.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
#! /usr/bin/env node
var minimist = require('minimist')
var loghose = require('./lib/loghose')
var through = require('through2')
module.exports = loghose
function cli () {
var argv = minimist(process.argv.slice(2), {
boolean: ['json'],
alias: {
'help': 'h',
'json': 'j',
'newline': 'n'
},
default: {
json: false,
newline: false
}
})
if (argv.help) {
console.log('Usage: docker-loghose [--json] [--newline] [--help]\n' +
' [--nameLabel label]\n' +
' [--matchByImage REGEXP] [--matchByName REGEXP]\n' +
' [--skipByImage REGEXP] [--skipByName REGEXP]\n' +
' [--addLabels] [--labelsKey keyname] [--labelsMatch REGEXP]')
process.exit(1)
}
loghose({
includeCurrentContainer: false,
nameLabel: argv.nameLabel,
matchByName: argv.matchByName,
matchByImage: argv.matchByImage,
skipByName: argv.skipByName,
skipByImage: argv.skipByImage,
addLabels: argv.addLabels,
labelsKey: argv.labelsKey,
labelsMatch: argv.labelsMatch,
newline: argv.newline,
json: argv.json
}).pipe(through.obj(function (chunk, enc, cb) {
this.push(JSON.stringify(chunk))
this.push('\n')
cb()
})).pipe(process.stdout)
}
if (require.main === module) {
cli()
}