From 2ba9d9045e0203315deb3e2c1f5588f6eb4f77d9 Mon Sep 17 00:00:00 2001 From: Dragan Bajcic Date: Sun, 25 Aug 2019 16:47:08 +0200 Subject: [PATCH] add monochrome mode --- README.md | 6 ++++++ bin/producer.js | 2 +- package-lock.json | 16 ++-------------- package.json | 5 +++-- splex.js | 19 ++++++++++++++----- 5 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b42ca74..c9690bc 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/bin/producer.js b/bin/producer.js index 282b37e..ba204c3 100644 --- a/bin/producer.js +++ b/bin/producer.js @@ -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(() => { diff --git a/package-lock.json b/package-lock.json index 4897b2c..6ef09f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -105,7 +105,8 @@ "faker": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz", - "integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8=" + "integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8=", + "dev": true }, "find-up": { "version": "2.1.0", @@ -125,14 +126,6 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, - "highland": { - "version": "2.13.5", - "resolved": "https://registry.npmjs.org/highland/-/highland-2.13.5.tgz", - "integrity": "sha512-dn2flPapIIAa4BtkB2ahjshg8iSJtrJtdhEb9/oiOrS5HMQTR/GuhFpqJ+11YBdtnl3AwWKvbZd1Uxr8uAmA7A==", - "requires": { - "util-deprecate": "^1.0.2" - } - }, "hosted-git-info": { "version": "2.8.4", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz", @@ -388,11 +381,6 @@ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-2.0.0.tgz", "integrity": "sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA=" }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, "validate-npm-package-license": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", diff --git a/package.json b/package.json index 127ce76..60c9434 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/splex.js b/splex.js index 29e085f..0e2c7c7 100755 --- a/splex.js +++ b/splex.js @@ -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: { @@ -27,7 +27,11 @@ Options: colors: { type: 'string', alias: 'c' - }, + }, + monochrome: { + type: 'boolean', + alias: 'm' + } } }); @@ -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}`)); }