Created
May 11, 2019 06:51
-
-
Save carsonfarmer/01d4d1ee8decf80e0b3ca1e49380c786 to your computer and use it in GitHub Desktop.
Adding some styling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/index.js b/index.js | |
index 963d96f..6e7bfc1 100644 | |
--- a/index.js | |
+++ b/index.js | |
@@ -3,6 +3,8 @@ | |
const cli = require('cac')('txtl') | |
const textile = require('@textile/js-http-client').default | |
var readline = require('readline') | |
+const chalk = require('chalk') | |
+const { emojify } = require('node-emoji') | |
const { log } = console | |
@@ -18,7 +20,7 @@ cli.command('', 'Starts an interactive chat session in a thread.') | |
// Run callback for each input on stdin | |
rl.on('line', (line) => { | |
if (line !== '') { | |
- textile.messages.add(opts.thread, line) | |
+ textile.messages.add(opts.thread, emojify(line)) | |
.then(() => { rl.prompt() }) | |
} | |
}) | |
@@ -26,7 +28,7 @@ cli.command('', 'Starts an interactive chat session in a thread.') | |
textile.profile.get() | |
.then((peer) => { | |
// ... and then create a custom prompt | |
- rl.setPrompt(peer.name || peer.address.slice(7) + '\t') | |
+ rl.setPrompt(chalk.green(peer.name || peer.address.slice(7)) + '\t') | |
rl.prompt() // Display prompt to get started | |
// Only subscribe to text events on the specified thread | |
textile.subscribe.stream(['TEXT'], opts.thread) | |
@@ -44,7 +46,7 @@ cli.command('', 'Starts an interactive chat session in a thread.') | |
if (item.user.address !== peer.address) { | |
readline.clearLine(process.stdout, 0) | |
readline.cursorTo(process.stdout, 0) | |
- log(name + '\t' + item.body) | |
+ log(chalk.cyan(name) + '\t' + chalk.grey(item.body)) | |
rl.prompt() | |
} | |
} catch (err) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment