Skip to content

Commit

Permalink
add monochrome mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kodi committed Aug 25, 2019
1 parent 6dc567a commit 2ba9d90
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 22 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ splex -t -c yellow,blue logs/log-0.log logs/log-1.log logs/log-2.log logs/log-3.

![custom colors](img/custom_colors.png)


Monochrome mode is activated by adding `-m` flag:

```
splex -tm logs/log-0.log logs/log-1.log logs/log-2.log
```
2 changes: 1 addition & 1 deletion bin/producer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const faker = require('faker');

const NUM_LOGS = 4;
const UPDATE_INTERVAL = 500;
const UPDATE_INTERVAL = 50;

let counter = 0;
let int = setInterval(() => {
Expand Down
16 changes: 2 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
"homepage": "https://github.com/kodi/splex#readme",
"dependencies": {
"chalk": "^2.4.2",
"faker": "^4.1.0",
"highland": "^2.13.5",
"meow": "^5.0.0",
"tail": "^2.0.3"
},
"devDependencies": {
"faker": "^4.1.0"
}
}
19 changes: 14 additions & 5 deletions splex.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Usage:
$ splex [options] file1 file 2 fileX
Options:
--table -t print as table rows
--colors -c specify custom colors as: color1, color2
--table -t print as table rows
--colors -c specify custom colors as: color1, color2
--monochrome -m monochrome mode
`, {
flags: {
table: {
Expand All @@ -27,7 +27,11 @@ Options:
colors: {
type: 'string',
alias: 'c'
},
},
monochrome: {
type: 'boolean',
alias: 'm'
}
}
});

Expand Down Expand Up @@ -69,9 +73,14 @@ filenames.forEach((f) => {
listeners[f] = new Tail(f);
listeners[f].on('line', (l) => {
let color = colorIdx[f];
if(cli.flags.t) {
if(cli.flags.t && !cli.flags.m) {
console.log(chalk[color](`> ${f}: `) + chalk.green('| ') + chalk.white(`${l}`));
console.log(chalk.green('-'.repeat(termSize)));
} else if (cli.flags.t && cli.flags.m) {
console.log(`> ${f}: | ${l}`);
console.log('-'.repeat(termSize));
} else if(cli.flags.m) {
console.log(`> ${f}: ${l}`);
} else {
console.log(chalk[color](`> ${f}: `) + chalk.white(`${l}`));
}
Expand Down

0 comments on commit 2ba9d90

Please sign in to comment.